Skip to content

mk-pmb/bind-all-methods-nondestructive-pmb-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published