fn-proxy
Simple function proxying. Allows for point-free recursion in JavaScrpipt, and simulation of lazy function evaluation.
Install
$ npm install fn-proxy
Run the specs (make sure jasmine-node
is installed)
$ npm test
Usage
Require the module
var proxy = ;
Examples
All examples show a point free recursive strategy for finding the length of a list. This would normally not be possible with regular JavaScript. Also note: examples use point-free style functions, something like ramda
or lodash
would provide.
- Explicit proxy - save proxy after declaration
var length = ; ; // => 0 // => 4
- Short-hand proxy chaining
var length = ; // => 0 // => 4
- Wrap declaration with proxy
var length = ; // => 0 // => 4
- Invoke the proxy directly
; // => 01 2 3 4 // => 4