var delegate = require('{%= name %}');
delegate(receiver, provider, clone);
Params
receiver
: (Object) The object receiving propertiesprovider
: (Object) The object providing properties
Copy properties and make them non-enumerable
var provider = {
upper: function(val) {
return val.toUpperCase();
},
lower: function(val) {
return val.toLowerCase();
}
};
var receiver = {};
// an existing properties in the `receiver`
// object would be overwritten
delegate(receiver, provider);
receiver.upper('foo');
receiver.lower('BAR');
console.log(receiver.upper('foo')); // 'FOO'
console.log(receiver.lower('BAR')); // 'bar'
// copied properties are non-enumerable
console.log(receiver); // {}
console.log(Object.keys(receiver)); // []
var obj = {
upper: function(val) {
return val.toUpperCase();
},
lower: function(val) {
return val.toLowerCase();
}
};
delegate(obj);
console.log(obj) // {}
obj.upper('foo') // 'FOO'
obj.lower('BAR') // 'bar'