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
| // The usual way | |
| var prepend = function (string, prefix) { | |
| return prefix.concat(string); | |
| }; | |
| prepend("foo", "bar_"); // Wait, what? Is this "foobar_" or "bar_foo"? Not obvious without seeing the function signature. | |
| // More natural language | |
| var prepend = function (string) { |
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
| let context = new AudioContext(); | |
| let noiseWorker = context.createAudioWorker("worker.js"); | |
| let noiseNode1 = context.createScriptProcessor(noiseWorker); | |
| let noiseNode2 = context.createScriptProcessor(noiseWorker); | |
| let oscillator = context.createOscillator(); | |
| noiseNode1.connect(oscillator.detune); | |
| noiseNode2.connect(context.destination); |
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
| class OffsetNode { | |
| constructor (context) { | |
| this.context = context; | |
| this.worker = this.context.createAudioWorker("worker.js"); | |
| this.node = this.context.createScriptProcessor(this.worker); | |
| this.initializeQueue(); | |
| } | |
| initializeQueue () { | |
| this.getOffsetQueue = []; |
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 createSentence = function () { | |
| var names = [].slice.call(arguments); | |
| var fn = names.pop(); | |
| if ( names.length === 0 ) { | |
| return fn; | |
| } | |
| var name = names.shift(); |
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
| "use strict"; | |
| var gulp = require("gulp"); | |
| var exec = require("gulp-exec"); | |
| var _ = require("lodash"); | |
| // This task will do nothing until it hasn't been triggered within 1s. | |
| gulp.task("exec", _.debounce(function () { | |
| return gulp.src(["..."], { read: false }) | |
| .pipe(exec("ctags -R")); |
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
| // method as a constructor. | |
| function MyClass () { | |
| this.isInitialized = false; | |
| } | |
| MyClass.prototype.initialize = function () { | |
| this.initialized = true; | |
| }; |
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
| "use strict"; | |
| module.exports = function (module, oddModule) { | |
| module.exports = function even (n) { | |
| return n == 0 || oddModule.exports(n - 1); | |
| }; | |
| }; |
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
| // localforage.js | |
| // if the module exports a promise, the loader waits until the promise resolves into something, | |
| // and that is what gets imported outside. | |
| export System.import("./IndexedDbDriver") | |
| .catch(=> System.import("./WebSqlDriver") ) | |
| .catch(=> System.import("./LocalStorageDriver") ); | |
| // IndexedDbDriver.js |
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 context = new AudioContext(); | |
| var audioWorker = context.createAudioWorker("worker.js"); | |
| var sine = context.createAudioWorkerNode(audioWorker, { | |
| numberOfInputChannels: 0, | |
| numberOfOutputChannels: 1, | |
| parameters: { | |
| frequency: 440, | |
| }, | |
| data: { | |
| type: "sine", |
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 context = new AudioContext(); | |
| var audioWorker = context.createAudioWorker("worker.js"); | |
| var sine1 = context.createAudioWorkerNode(audioWorker, { | |
| numberOfInputChannels: 0, | |
| numberOfOutputChannels: 1, | |
| parameters: { | |
| frequency: 440, | |
| }, | |
| }); | |
| var sine2 = context.createAudioWorkerNode(audioWorker, { |
OlderNewer