Skip to content

Instantly share code, notes, and snippets.

@creationix
Created February 19, 2010 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creationix/308956 to your computer and use it in GitHub Desktop.
Save creationix/308956 to your computer and use it in GitHub Desktop.
// Super simplified sample library
fs.readFile = function (filename, another_arg, more args, callback) {
callback(error, content);
}
// Curried
fs.readFile = function (filename, another_arg, more args) { return function (callback) {
callback(error, content);
}}
// base arg with options hash
fs.readFile = function (filename, {encoding: "ascii"}, callback) {
callback(error, content);
}
// Promise people could do this
promise(fs.readFile, "myfile").then(function (data) {...})
// Or even this
when(fs.readFile, "myfile", function (data) {...})
// Continuable people could do this
cont(fs.readFile, "myfile")(function (data) {...})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment