https://github.com/doowb/delegate-object
Copy properties from an object to another object, where properties with function values will be invoked in the context of the receiver, and properties with non-function values are just copied.
https://github.com/doowb/delegate-object
Last synced: about 1 month ago
JSON representation
Copy properties from an object to another object, where properties with function values will be invoked in the context of the receiver, and properties with non-function values are just copied.
- Host: GitHub
- URL: https://github.com/doowb/delegate-object
- Owner: doowb
- License: mit
- Created: 2015-08-07T01:07:38.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-16T02:57:01.000Z (over 9 years ago)
- Last Synced: 2024-05-01T22:07:23.440Z (12 months ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# delegate-object [](http://badge.fury.io/js/delegate-object) [](https://travis-ci.org/doowb/delegate-object)
> Copy properties from an object to another object, where properties with function values will be invoked in the context of the receiver, and properties with non-function values are just copied.
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i delegate-object --save
```## Usage
```js
var delegateObject = require('delegate-object');
```## API
### [delegate](index.js#L36)
Copy properties from an object to another object, where properties with function values will be invoked in the context of the receiver, and properties with non-function values are just copied.
**Params**
* `receiver` **{Object}**: Object to receive properties.
* `provider` **{Object}**: Object providing properties.
* `keys` **{Array}**: Optional array of keys to delegate.
* `returns` **{Object}**: Modified `receiver` object with properties from `provider`**Example**
```js
var receiver = {};
var provider = {
name: 'provider',
upper: function (str) {
return '[' + this.name + '] ' + str.toUpperCase();
}
};
var receiver = delegate(receiver, provider);
receiver.name = 'receiver';
console.log(receiver.upper('foo'));
//=> [receiver] FOO
```## Related projects
## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/doowb/delegate-object/issues/new)
## Author
**Brian Woodward**
+ [github/doowb](https://github.com/doowb)
+ [twitter/doowb](http://twitter.com/doowb)## License
Copyright © 2015 Brian Woodward
Released under the MIT license.***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 07, 2015._