adhere

1.2.3 • Public • Published

Wrap methods preserving arity.

Synopsis

The adhere method allows you to define a function factory that wraps a user function, but preserving the airty of the wrapped function.

var switcharoo = function (method) {
    return adhere(method, function (object, vargs) {
        vargs.reverse()
        method.apply(object, vargs)
    })
}

var reversed = switcharoo(function (a, b) { return [ a, b ] })

assert.deepEqual(reversed(1, 2), [ 2, 1 ], 'reversed')

This airty preservation has been extracted from Cadence. This function builder is used to preserve airty in Pointcut.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.2.3
    247
    • latest

Version History

Package Sidebar

Install

npm i adhere

Weekly Downloads

252

Version

1.2.3

License

MIT

Unpacked Size

4.28 kB

Total Files

4

Last publish

Collaborators

  • bigeasy