Skip to content

Instantly share code, notes, and snippets.

@sharmaabhinav
Last active January 8, 2019 16:49
Show Gist options
  • Save sharmaabhinav/cb4bea962021059d802049a1402c7883 to your computer and use it in GitHub Desktop.
Save sharmaabhinav/cb4bea962021059d802049a1402c7883 to your computer and use it in GitHub Desktop.
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