Need private packages and team management tools?Check out npm Teams »

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

0

Version

0.3.1

License

MIT

Last publish

Collaborators

  • avatar