This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // non-modular | |
| jQuery.fn.limit = function(count){ | |
| return $(this).filter(function(index){ return index < count; }); | |
| }; | |
| // non-modular usage | |
| $('sel').limit(3); | |
| // modular | |
| var $ = require('jquery'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if ('serviceWorker' in navigator) { | |
| navigator.serviceWorker.register('service-worker.js').then(function(registration) { | |
| // Registration was successful | |
| console.log('ServiceWorker registration successful with scope: ', registration.scope); | |
| registration.pushManager.subscribe().then(function(subscription){ | |
| isPushEnabled = true; | |
| console.log("subscription.subscriptionId: ", subscription.subscriptionId); | |
| console.log("subscription.endpoint: ", subscription.endpoint); | |
| // TODO: Send the subscription subscription.endpoint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var gulp = require('gulp'); | |
| var sourcemaps = require('gulp-sourcemaps'); | |
| var source = require('vinyl-source-stream'); | |
| var buffer = require('vinyl-buffer'); | |
| var browserify = require('browserify'); | |
| var watchify = require('watchify'); | |
| var babel = require('babelify'); | |
| function compile(watch) { | |
| var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Make punctuation smarter | |
| jQuery.fn.smarten = (function() { | |
| function smartenNode(node) { | |
| if (node.nodeType === 3) { | |
| node.data = node.data | |
| .replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018") // Opening singles | |
| .replace(/'/g, "\u2019") // Closing singles & apostrophes | |
| .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201c") // Opening doubles | |
| .replace(/"/g, "\u201d") // Closing doubles |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "env": { | |
| "browser": true, | |
| "builtin": true, | |
| "jasmine": true, | |
| "mocha": true, | |
| "node": true | |
| }, | |
| "extends": "airbnb", | |
| "globals": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [libs] | |
| [ignore] | |
| [options] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "presets": [ | |
| "stage-2", | |
| "es2015" | |
| ], | |
| "plugins": [ | |
| "transform-flow-strip-types", | |
| "transform-object-assign", | |
| "transform-class-properties", | |
| "transform-runtime" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Logs | |
| logs | |
| *.log | |
| npm-debug.log* | |
| # compiled js | |
| dist | |
| # Dependency directories | |
| node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| src | |
| .idea/ | |
| node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Get a random floating point number between `min` and `max`. | |
| * | |
| * @param {number} min - min number | |
| * @param {number} max - max number | |
| * @return {float} a random floating point number | |
| */ | |
| function getRandom(min, max) { | |
| return Math.random() * (max - min) + min; | |
| } |