result-core
Minimal function call reification. This library is designed both to be useful in simple cases and serve as a specification for how alternative implementations should behave. See result and lazy-result for examples. Note how they inherit from this class, making them easy to distinguish from other types. No duck typing required. This makes general purpose utilities such as when much easier to write.
Installation
With component, packin or npm
$ {package mananger} install jkroso/result-core
then in your app:
var Result = require('result-core')
API
Result()
A class for creating concrete representations of function calls which can be manipulated programmatically at run-time.
function add(a, b){
var result = new Result
result.write(a + b)
return result
}
add(1, 2).read(function(three){
console.log('1 + 2 = %d', three)
})
FAQ
Q: How the fuck is that useful?
A: async programming
Running the tests
Just run make
. It will install and start a development server so all you then need to do is point your browser to localhost:3000/test
. Likewise to run the Koans.