Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alsotang/ettr
https://github.com/alsotang/ettr
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/alsotang/ettr
- Owner: alsotang
- Created: 2014-10-03T04:48:15.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-04T15:43:46.000Z (almost 10 years ago)
- Last Synced: 2024-10-10T23:35:22.542Z (3 months ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/alsotang/ettr.svg)](https://travis-ci.org/alsotang/ettr) [![Coverage Status](https://img.shields.io/coveralls/alsotang/ettr.svg)](https://coveralls.io/r/alsotang/ettr)
install
==`npm install ettr`
usage
==Assume `obj` is
```js
{
a: {
b: {
c: 1,
d: 2,
}
}
}
```### .get(obj, attr)
```js
ettr.get(obj, 'a.b.c')
.should.equal(1);ettr.get(obj, 'a[b]["c"]')
.should.equal(1);
```### .set(obj, attr, value)
```js
ettr.set(obj, 'a.b.c', 5);
obj.a.b.c.should.equal(5);
```### .incr(obj, attr, value, defaultValue)
```js
ettr.incr(obj, 'a.b.z', 1, 100);
ettr.incr(obj, 'a.b.z', 1, 100);
obj.a.b.z.should.equal(102);
```benchmark
==see `benchmark.js`
```
#ettr x 800,747 ops/sec ±2.25% (93 runs sampled)
#eval x 2,918,739 ops/sec ±2.65% (87 runs sampled)
Fastest is #eval
```license
==MIT