bind-all-methods-nondestructive-pmb

0.1.0 • Public • Published

bind-all-methods-nondestructive-pmb

Flat-copy an object except all methods are bound to a given context. Do not modify the origin object.

API

This module exports one function that holds some methods:

bindAllMethods(context, origin)

Alias for bindAllMethods.onto({}, context, origin).

bindAllMethods.dest(dest, origin)

Alias for bindAllMethods.onto(dest, dest, origin).

May be used to install additional APIs onto an existing object without affecting unrelated methods.

bindAllMethods.onto(dest, context[, origin])

If origin is false-y, context is used instead.

Copy all properties of origin onto dest, except methods. For methods, instead, assign a version that is bound to context. Return dest.

Usage

see test/usage.mjs.

Known issues

  • Needs more/better tests and docs.

 

License

ISC

Package Sidebar

Install

npm i bind-all-methods-nondestructive-pmb

Weekly Downloads

1

Version

0.1.0

License

ISC

Unpacked Size

4.45 kB

Total Files

5

Last publish

Collaborators

  • mk-pmb