Skip to content

Qix-/node-emplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-emplace Travis-CI.org Build Status Coveralls.io Coverage Rating

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 .clears the object, then .appends to it.

See example.

License

Licensed under the MIT License. You can find a copy of it in LICENSE.

About

Emplace objects and arrays - pointer to pointer style!

Resources

License

Stars

Watchers

Forks

Packages

No packages published