Last active
January 8, 2019 16:49
-
-
Save sharmaabhinav/cb4bea962021059d802049a1402c7883 to your computer and use it in GitHub Desktop.
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 cacheData = { | |
'url1' : {a: 3} | |
} | |
// not completely async | |
function ajax (url, fn) { | |
if (cacheData[url]) { | |
fn(cacheData[url]) | |
return | |
} | |
setTimeout(() => fn({a: 2}), 0) | |
} | |
function result(data) { | |
console.log( a, data ); | |
} | |
var a = 0; | |
// make result call async | |
ajax( "url2", result ); | |
a++; | |
// permutation ['abc'] => ['abc', 'acb', 'bca', 'bac', 'cab', 'cba'] | |
// combination ['abc'] => ['a', 'b', 'c', 'ab', 'bc', 'ac', 'abc'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment