thisize
Converts normal functions to methods. This is mostly useful for the es7 ::
operator which
allows chaining with simple functions.
Install
It's available on npm. It has no dependencies so you can grab a wzrd.in standalone build.
npm install --save thisize@0.1
thisize(fn, thisArgIndex=0)
Say you have the function first
:
{ return xs0;} === 'a';
You could thisize it which uses the this
context instead of the first argument.
=== 'a';
You can specify an index relative to the start of the argument list, or the end (if you need this for some reason).
For example:
var readFile = ; { ... }; // the following are equivilenthandleResponse::;readFile;fs;
Useful examples!
Think about the places we use chaining in JS, for example, jQuery plugins!
{ el; return el;} ;setColor;
And then it can be used in a functional manner:
; ;
Or with the es7 ::
operator:
; :: text'Cool?'
Either way is fine, and not having to pollute $.fn is a win.