npm

npm’s 2019 JavaScript ecosystem survey analysis is now available! Get your copy here »

redefine-properties

1.0.0 • Public • Published

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;
 

install

npm i redefine-properties

Downloadsweekly downloads

1

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability