resultify

convert node functions to Result returning ones

resultify

convert node functions to Result returning ones

With component, packin or npm

$ {package mananger} install jkroso/resultify

then in your app:

var resultify = require('resultify')

Teach a node function all about the Result type

var readFile = resultify(fs.readFile)
readFile('/path/to/file.js', 'utf8').then(function(src){
  process.stdout.write(src)
})

just a copy of the fs module from node but with all of the async functions run through the above function

Results are like dataflow variables. If all the functions in your program understand them you can hardly tell your code isn't blocking.

fs.readFile(prompt('which file? '), 'utf8').read(function(file){
    console.log(file)
})

once a function has been decorated with resultify it will incur an extra 700-1000ns per invocation which is nothing to worry about. To put that in perspective a function bound with .bind() will become 1500-2000ns slower. Tested on a mac air with node@v0.10.12

Just run make test