Skip to content

Instantly share code, notes, and snippets.

@EvanCarroll
Last active January 3, 2016 22:59
Show Gist options
  • Save EvanCarroll/8531891 to your computer and use it in GitHub Desktop.
Save EvanCarroll/8531891 to your computer and use it in GitHub Desktop.
Thunk fun.
var thunkify = require('./index.js');
function wtf ( cb ) {
console.log('start');
// Function, expecting callback triggers twice
cb( 'HELLO 1' );
cb( 'HELLO 2' );
cb( 'HELLO 3' );
console.log('done');
return;
}
var thunk = thunkify(wtf); // now we have thunk
var invoke = thunk(); // now we invoke without any args, or callback
setTimeout( function () {
// Now we set callback.
invoke(
function () { console.log( 'good', arguments ) }
);
} ,1000 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment