delegate-properties
Deep-clone properties from one object to another and make them non-enumerable, or make existing properties on an object non-enumerable.
Install
Install with npm
$ npm i delegate-properties --save
Usage
var delegate = require('delegate-properties');
delegate(receiver, provider, clone);
Params
receiver
: (Object) The object receiving propertiesprovider
: (Object) The object providing propertiesclone
: (Boolean) Pass true
to deep clone the provider object
Examples
copy properties
Copy properties and make them non-enumerable
var provider = {
upper: function(val) {
return val.toUpperCase();
},
lower: function(val) {
return val.toLowerCase();
}
};
var receiver = {};
delegate(receiver, provider);
receiver.upper('foo'), 'FOO');
receiver.lower('BAR'), 'bar');
console.log(receiver.upper('foo'));
console.log(receiver.lower('BAR'));
console.log(receiver);
console.log(Object.keys(receiver));
make existing properties non-enumerable
var obj = {
upper: function(val) {
return val.toUpperCase();
},
lower: function(val) {
return val.toLowerCase();
}
};
delegate(obj);
console.log(obj)
obj.upper('foo')
obj.lower('BAR')
Related projects
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
This file was generated by verb-cli on September 06, 2015.