JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 186
  • Score
    100M100P100Q73729F
  • License MIT

Wrap methods preserving arity.

Package Exports

  • adhere

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (adhere) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.