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 flatten(a) { | |
return Array.isArray(a) ? [].concat.apply([], a.map(flatten)) : [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
async(function*() { | |
console.log('start'); | |
yield asyncFunction(); | |
var value = yield asyncFunction(); | |
console.log('value', value); | |
}); | |
function asyncFunction() { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { |
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 (!Object.prototype.assign) { | |
Object.prototype.assign = function() { | |
var args = [].slice.call(arguments), | |
target = args.shift(); | |
return args.reduce(function(base, obj) { | |
Object.keys(obj).forEach(function(prop) { | |
if (obj.hasOwnProperty(prop)) { | |
base[prop] = obj[prop]; | |
} |
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 debounce = function(func, wait) { | |
// we need to save these in the closure | |
var timeout, args, context, timestamp; | |
return function() { | |
// save details of latest call | |
context = this; | |
args = [].slice.call(arguments, 0); | |
timestamp = new Date(); |
NewerOlder