1.0.0 • Published 10 years ago

redefine-properties v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

Redefine Properties

Merge multiple objects' properties into target by redefining properties using extracted property descriptors.

  • Works with multiple sources.
  • Copies all own properties including nonenumerable ones.
  • Uses Object.defineProperty for all properties.
  • In case of conflict the last source of a property wins.

NB: Mutates the first argument!

Example

var redefine = require('redefine-properties');

var source = {
  get a() {
    return 42;
  }
};
var target = {};

redefine(target, source);

target.a === 42;