node package manager



Utility methods for node.js.


    npm install utility-methods


    var utility = require('utility-methods');

    console.log(utility.max(0, 1, 2, -1)); // Output: 2


Within utility-methods souce directory, type:

    npm test


createInvokeChain(array functions)

Return a function which on invocation will invoke all functions within [functions]. All functions will be invoked with a 'next' handler as last argument, with the exception of the last function which is replaced with any error, if any.

_if(function expression, function onTrue, function onFalse)

Return a handler, that on invocation will forward all its arguments together with a 'next' handler to [expression]. [expression] should then invoke its 'next' handler with either true or false. Depending on the result, either [onTrue] or [onFalse] will be invoked.

max(val1, val2, val 3, ..., valN)

Return the greatest value that was provided. Supports unlimited number of arguments.

createInvokeBarrier(int num, function cb)

Return a function that will wait [num] times before any call [cb] will be forwarded.

createTimedHandler(ms, cb)

Return a function that will wait [ms] ms before cb in be automatically invoked with a timeout error if the function has not been invoked before that. The function will quarantee that [cb] is only invoked once.