Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qix-/node-emplace
Emplace objects and arrays - pointer to pointer style!
https://github.com/qix-/node-emplace
Last synced: 26 days ago
JSON representation
Emplace objects and arrays - pointer to pointer style!
- Host: GitHub
- URL: https://github.com/qix-/node-emplace
- Owner: Qix-
- License: mit
- Created: 2015-08-24T04:33:43.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-26T21:47:50.000Z (about 9 years ago)
- Last Synced: 2024-10-19T07:52:56.441Z (about 1 month ago)
- Language: CoffeeScript
- Size: 133 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-emplace [![Travis-CI.org Build Status](https://img.shields.io/travis/Qix-/node-emplace.svg?style=flat-square)](https://travis-ci.org/Qix-/node-emplace) [![Coveralls.io Coverage Rating](https://img.shields.io/coveralls/Qix-/node-emplace.svg?style=flat-square)](https://coveralls.io/r/Qix-/node-emplace)
> Emplace objects and arrays - pointer to pointer style!## Example
```javascript
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.```javascript
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).```javascript
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](#example).
## License
Licensed under the [MIT License](http://opensource.org/licenses/MIT).
You can find a copy of it in [LICENSE](LICENSE).