PR of initial master commits

Should the checking against maxDelay be in a separate function, so that the user only needs to implement the calculation bit, not the checking against max too?

Also consider making this function asynchronous. You never know how someone will want to implement it and supporting a callback is the node.js way of doing things.