Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

emplace

0.3.1 • Public • Published

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.

install

npm i emplace

Downloadsweekly downloads

7

version

0.3.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability