lift functions so they can handle Results as if they were plain values
lift functions so they can handle results as if they were plain values.
With your favourite package manager:
packin add lift-result
component install jkroso/lift-result
npm install lift-result
then in your app:
var lift = require'lift-result'var liftCPS = require'lift-result/cps'var apply = require'lift-result/apply'var sexpr = require'lift-result/sexpr'
fn so it can receive promises as arguments. Return
values will be unboxed wherever possible however errors will
be caught and boxed with a promise since this means you don't
have to handle sync and async errors separately.
var Result = require'result'var add = lift return a + badd1 2 // => 3addResultwrap1 2 // => 3var one =var answer = addone 2 // => new Resultonewrite1answervalue // => 3
decorate a node function so it can receive Results as arguments and will return a result rather than take a callback as its last argument.
var fs = require'fs'var readFile = liftCPSfsreadFilereadFile'Readme.md'readbuf // => fs.readFileSync('Readme.md')
apply arguments to the last argument
applyResultwrap1 2 Array // => [1, 2]
apply rest of args to
sexprArray Resultwrap1 2 // => [1, 2]