UFCS.js
DLang's Uniform Function Call Syntax (UFCS) port to JavaScript
It's mutates the
Object.prototype
, be careful when you are using it.
Install
npm install ufcs
Overview
A free function can be called with a syntax that looks as if the function were a member function of its first parameter type.
Uniform Wrapper
Just wrap the function and ufcs
will handle rest.
var uniform = ; ; { return x + y;} var result = ; //=> 5var result = 2; //=> 5
Chaining
Since it mutates Object.prototype
you can use it with every type. So, you can chain the function.
var result = ; //=> 2 + 3 + 4 + 5 = 14
License
MIT.