merg-descripters
v2.0.1
Published
Merge objects using their property descriptors
Maintainers
Readme
merge-descripters
Merge objects using their property descripters.
A lightweight utility for merging objects while preserving property descriptors, including getters, setters, and non-enumerable properties.
📦 Installation
npm install merge-descripters🚀 Usage
import mergeDescriptors from 'merge-descripters';
const thing = {
get name() {
return 'test';
}
};
const animal = {};
mergeDescriptors(animal, thing);
console.log(animal.name);
//=> 'test'🔧 API
merge(destination, source, overwrite?)
Merges own properties from a source object into a destination object, while preserving property descriptors.
This includes non-enumerable properties and accessor properties (getters/setters).
Returns the modified destination object.
Parameters
destination(object)
The object that will receive properties.source(object)
The object providing properties.overwrite(boolean) (default:true)
Whether to overwrite existing properties on the destination object.
📜 License
MIT © cybertest12
