Skip to content

neu-rah/rbinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rbinder

bind function last parameter (right side)

This tiny module offers a bind like functionality but binds to the last parameter.

var rbinder=require("rbinder");
function f() {return arguments;}
rbinder(f);//now functions f has an rbind member
f.rbind(1)(2);// should return a 2 parameters argument

you can patch all functions of your module at once

var rbinder=require("rbinder");
rbinder(Function.prototype);//bind all module functions
f.rbind(1)(2);// should return a 2 parameters argument

However functions from imported modules wont be patched by last trick. They still can be patched individually by rbinder.

This patch can be applied to all imported module functions of a particular module, by hooking to any imported function prototype like this:

rbinder(fs.readFile.constructor.prototype)
fs.readFile.rbind(...);//now fs.readFile has a rbind functions
fs.write.rbind(...);//as well as all the other functions of fs module

About

node bind last function parameter (right side)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published