emplace
v0.3.1
Published
Emplace objects and arrays - pointer to pointer style!
Downloads
5
Maintainers
Readme
node-emplace
Emplace objects and arrays - pointer to pointer style!
Example
var emplace = require('emplace');
var obj = {foo: 1234};
var obj2 = {bar: 'hello'};
emplace.replace(obj, obj2);
console.log(obj.foo); //-> undefined
console.log(obj.bar); //-> hello
API
.clear(obj)
Clears an object's properties in-place.
var obj = {foo: 1234};
emplace.clear(obj);
console.log('foo' in obj); //-> false
.append(obj, otherObj)
Either appends an array, or merges two objects (overwriting duplicate keys).
var obj = {foo: 1234};
var obj2 = {bar: 'hello'};
emplace.append(obj, obj2);
console.log(obj.foo); //-> 1234
console.log(obj.bar); //-> 'hello'
.replace(obj, otherObj)
First .clear
s the object, then .append
s to it.
See example.
License
Licensed under the MIT License. You can find a copy of it in LICENSE.