File: README.md

package info (click to toggle)
node-object-key 0.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 92 kB
  • sloc: makefile: 10; sh: 2
file content (35 lines) | stat: -rw-r--r-- 708 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# object-key

Assing value to an object property using path string separated by dots and lookup values using the same dot separated string paths.

## Usage

### ok.assign(key, value, hash[, stringCase])

`stringCase` might be:

- camel
- kebab
- snake

```
const ok = require('ok');

var path = 'foo.bar.baz';
var path2 = 'foo.barBar.baz';
var obj = {};

ok.assign(obj, path, 'some value');  // { foo: { bar: { baz: 'some value' }}}
ok.assign(obj, path2, 'some value', 'kebab');  // { foo: { 'bar-bar': { baz: 'some value' }}}
```

### ok.lookup(key, hash)

```
const ok = require('ok');

var path = 'foo.bar.baz';
var obj = { foo: { bar: { baz: 'some value' }}};

ok.lookup(path, obj);  // 'some value'
```