funstance
make an instance callable like a function
example
funstantiate a prototypical object
foo.js:
var inherits = ;var Stream = ;moduleexports = Foo;;{thisx = x;}Fooprototype {this;};
main.js:
var funstance = ;var Foo = ;var obj = 4;var fobj =console;fobj;fobj;
Note that .on()
is defined all the way in EventEmitter, which is 3 times
removed up the prototype chain from fobj
, yet fobj.on()
still works despite
being a function.
$ node main.js
444
boop
methods
var funstance =
var fobj = funstance(obj, fn)
Return a function with all the properties and prototypical methods as obj
.
When fobj()
is called, fn()
will fire with the arguments and this
set to
the obj
.
Note that obj
shouldn't be an Array or possibly other built-in types aside
from Object since some of them behave strangely for performance reasons.
install
With npm do:
npm install funstance
license
MIT