node-dynamic-function
Easily create functions with dynamic name and length. This is useful for wrapping functions without f'ing up their name and length.
Install
npm install --save dynamic-function
Usage
const dynamicFunction = ; { /* ... */} const wrappedFunction = ; console; // logs 'wrapped_originalFunction'console; // logs 2 console; // function wrapped_originalFunction(originalArg1, originalArg2) {// /* ... */// }
API
dynamicFunction ( func [, options] )
func : function options : object (optional) options.bind : object (default: null) options.name : string (default: '') options.length : number (default: 0)
Performance
Some environments (eg. NodeJS < 4.x.x) don't support renaming functions with Object.defineProperty
. In this case there is a fallback to eval
.
eval
a relatively slow JavaScript feature. Avoid (over)using this in situations where high performance is required.
At start-up (for Server applications) / low load situations using this should pose no problem.