delegate-properties
Deep-clone properties from one object to another and make them non-enumerable, or make existing properties on an object non-enumerable.
Last updated 10 years ago by jonschlinkert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install delegate-properties 
SYNC missed versions from official npm registry.

delegate-properties NPM version NPM downloads Build Status

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 install --save delegate-properties

Usage

var delegate = require('delegate-properties');
delegate(receiver, provider, clone);

Params

  • receiver: (Object) The object receiving properties
  • provider: (Object) The object providing properties

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 = {};
// 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)); // []

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') // 'FOO'
obj.lower('BAR') // 'bar'

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.


This file was generated by verb-generate-readme, v0.1.30, on August 13, 2016.

Current Tags

  • 0.4.0                                ...           latest (10 years ago)

6 Versions

  • 0.4.0                                ...           10 years ago
  • 0.3.0                                ...           11 years ago
  • 0.2.1                                ...           11 years ago
  • 0.2.0                                ...           11 years ago
  • 0.1.2                                ...           11 years ago
  • 0.1.1                                ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (2)
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |