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 ASYNC = { | |
| then: function then(o) { | |
| typeof o === 'function' ? o() : false; | |
| return { | |
| then : this.then, | |
| defer : this.defer | |
| } | |
| }, | |
| defer: function then(o,t) { | |
| return new Promise(function(res,rej) { |
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
| //Combaine promise with generator | |
| function *getUrl(url) { | |
| try { | |
| var response = yield getReq(url).then(function(fb) { | |
| console.log('feedback!!!'); | |
| console.log(fb); | |
| return fb; | |
| }, | |
| function(e) { |
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
| // is Number this = global scope (window) | |
| if(typeof this.isN != "function" && (this.constructor.name).toLowerCase() === "window") { | |
| this.isN = function (...args) { | |
| let newArgs = []; | |
| newArgs = args.map((e) => { | |
| return !isNaN(e) | |
| }); | |
| return newArgs; | |
| }; | |
| } |
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 cat = new Cat() // it's ok ! | |
| cat.sayHello(); // then we call sayHello without any problem! | |
| function Cat() { | |
| this.sayHello = function() { | |
| console.log('hello Im a cat'); | |
| } | |
| } | |
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 a = 2; | |
| var Obj = { | |
| a: 4, | |
| test: () => { | |
| console.log(a); | |
| console.log(this.a); | |
| }, | |
| test2: function({a = 6}) { | |
| console.log(a); |
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 a = [1,2,3,4,5,6,7,8,9,0], | |
| tmp = 0, | |
| it = a[Symbol.iterator](); | |
| do { | |
| tmp = it.next(); | |
| if(tmp.value != undefined) { | |
| console.log(`Value is: ${tmp.value}`); | |
| } | |
| } while(!tmp.done) |
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 test(...args) { | |
| try { | |
| var cb = args.pop(); | |
| (cb.constructor.name === 'Function') ? null : new Error('isnt fn'); | |
| let a = args, | |
| tmp = 0, | |
| it = a[Symbol.iterator](); | |
| do { | |
| tmp = it.next(); | |
| if(tmp.value != undefined) { |
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
| /** | |
| * distro. | |
| * @module distro. | |
| * @version 1.0.0 | |
| * | |
| * @author ppraksa | |
| * @copyright (c) 2017 ppraksa. | |
| */ | |
| const distro = {}, |
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
| Object.prototype.mixin = function(obj) { | |
| if(typeof obj === 'object') { | |
| for(let i in obj) { | |
| String(i) in this ? `${i} - property exist` : this[i] = obj[i]; | |
| } | |
| } | |
| } | |
| var Vehicle = { works: true, tank: 100, hasWheels: 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
| Object.prototype.parasiteCopy = function(obj, args) { | |
| if(typeof obj.constructor === 'function') { | |
| obj.apply(this, args); | |
| } | |
| } | |
| var Plant = function(colour,roots) { | |
| this.colour = colour; | |
| this.roots = roots | |
| } |
OlderNewer