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 Point2D = function (x, y) { | |
| if (x === null || x === undefined) { x = 1; } | |
| if (y === null || y === undefined) { y = 1; } | |
| this.x = x; | |
| this.y = y; | |
| }; | |
| Point2D.prototype = { | |
| equals: function () { |
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 Range { | |
| constructor(start, stop=start) { | |
| if (start === undefined && stop === undefined) { | |
| throw 'usage: range(start, stop) or range(stop)'; | |
| } | |
| if (stop === start) { | |
| start = 0; | |
| } |
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
| const logicGates = { | |
| nand (a, b) { return !(a && b); }, | |
| not (a) { return this.nand (a, a); }, | |
| and (a, b) { return this.not (this.nand (a, b)); }, | |
| or (a, b) { return this.nand (this.not (a), this.not(b)); }, | |
| nor (a, b) { return this.not (this.or (a, b)); }, | |
| xor (a, b) { return this.and (this.nand (a, b), this.or(a, b)); }, | |
| xnor (a, b) { return this.not (this.xor (a, b)); } | |
| }; |
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
| const logicGates = { | |
| nand(a, b) { | |
| return !(a && b); | |
| }, | |
| not(a) { | |
| return this.nand(a, a); | |
| }, | |
| and(a, b) { | |
| return this.not(this.nand(a, b)); | |
| }, |
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
| async function func () { | |
| const url = 'https://maps.googleapis.com/maps/api/geocode/json?address=94043&sensor=false'; | |
| const { results: [ result ] } = await fetch(url).then((response) => response.json()); | |
| return JSON.stringify(result, null, 2); | |
| } | |
| func().then(console.log.bind(console)); | |
| /* |
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
| [data-ember-action] { | |
| cursor: pointer; | |
| } |
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
| export default Ember.View.reopen({ | |
| init() { | |
| this._super.apply(this, arguments); | |
| // bind attributes beginning with 'data-' | |
| Em.keys(this) | |
| .filter(key => key.substr(0, 5) === 'data-') | |
| .forEach(key => this.get('attributeBindings').pushObject(key)); | |
| } | |
| }); |
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
| function* generatorDelegate () { | |
| var name = 'generatorDelegate'; | |
| yield `${name}: 1`; | |
| yield `${name}: 2`; | |
| yield `${name}: 3`; | |
| } | |
| function* generator () { | |
| var name = 'generator'; | |
| yield `${name}: 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
| function* fromOneTo (max) { | |
| var i = 0; | |
| while (max--) { | |
| yield ++i; | |
| } | |
| }; | |
| for (var i of fromOneTo(100)) { | |
| var 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
| /* globals module */ | |
| 'using strict'; | |
| module.exports = function (options) { | |
| if (arguments.length === 2) { | |
| options = { | |
| body: arguments[0], | |
| match: arguments[1] | |
| }; |
NewerOlder