cmd + [
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 co = require('co') | |
var arry = [1, 2, 3, 4, 5] | |
var asyncFunc = function(t) { | |
return new Promise(function(resolve, reject) { | |
setTimeout(function() { | |
resolve(t) | |
}, 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
var map = {} | |
var key | |
var count = 1000000 | |
for(var i=0; i< count; i++){ | |
key = Math.random() | |
if(map[key]) { | |
console.log(key) | |
console.log('dumplicate') | |
break |
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
// A->B->D | |
// A!>C | |
var when = require('when'); | |
function A(ok) { | |
console.log('running : A') | |
var defer = when.defer() | |
setTimeout(function() { | |
if (ok) { |
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(){ | |
console.log('hello') | |
} |