This is a utility library used by concurix-monitor. We suggest you check out that library as it will automatically apply this wrapper with logic for integration with the Concurix service.
Unlike simple function wrappers, the returned proxy tries to mimic the wrapped function as closely as possible (including properties and name)
To get the most out of this module, you can optionally expose V8's debug as a symbol this module will look for:
node --expose-debug-as=v8debug app.js
var wrap = require"concurix-wrap";// A silly prime number findervar primes = 2 j isPrime i = 3while primeslength < nisPrime = truefor j = 0; j < primeslength; j++if i % primesj === 0isPrime = falsebreak;if isPrime primespushi;i+=2;return primes;findPrimes = wrapfindPrimesbeforeconsole.log"Starting `findPrimes()` at %s" ;afterconsole.log"Finished `findPrimes()` at %s" ;getProxy;var result = findPrimes100000;console.logresultresultlength - 1;/*Starting `findPrimes()` at Tue Nov 19 2013 12:25:31 GMT-0800 (PST)Finished `findPrimes()` at Tue Nov 19 2013 12:25:59 GMT-0800 (PST)1299709*/
Wrap a function with a proxy that allows you to trigger behavior before or after execution.
Retreive the proxy function that will perform the original task with your added hooks.
fn before the wrapped function begins.
fn after the wrapped function completes. This does not follow asynchronous continuations.
Retreive the original function from the wrapper, unmodified.