Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tarabyte/redefine-properties

Define properties using multiple source objects
https://github.com/tarabyte/redefine-properties

Last synced: about 2 months ago
JSON representation

Define properties using multiple source objects

Awesome Lists containing this project

README

        

# 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
```javascript
var redefine = require('redefine-properties');

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

redefine(target, source);

target.a === 42;

```