bind-all-methods-nondestructive-pmb
v0.1.0
Published
Flat-copy an object except all methods are bound to a given context. Do not modify the origin object.
Downloads
3
Maintainers
Readme
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