An open API service indexing awesome lists of open source software.

https://github.com/heapwolf/object-path

Get and Set values on an object using dot-paths
https://github.com/heapwolf/object-path

Last synced: 2 months ago
JSON representation

Get and Set values on an object using dot-paths

Awesome Lists containing this project

README

        

# SYNOPSIS
Subset implementation of object-path, `get` and `set` methods.

# INSTALL

```bash
npm install heapwolf/object-path
```

# USAGE

```js
const { get, set } = require('object-path')
```

```js
const o = {
a: {
b: {
c: ['foo', 'bar', 'bazz']
}
}
}
```

```js
get(o, 'a.b.c.1') // => 'bar'
get(o, 'a.b.c') // => ['foo', 'bar', 'bazz']
```

```js
set(o, 'a.b.c.0', { x: true }) // => [{ x: true }, 'bar', 'bazz']
```

```js
set({}, 'a.y.2.z', 100) // => { a: { y: [null, null, { z: 100 }] } }
```