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
- Host: GitHub
- URL: https://github.com/heapwolf/object-path
- Owner: heapwolf
- Created: 2019-03-19T16:01:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-19T16:29:10.000Z (about 6 years ago)
- Last Synced: 2025-01-24T10:47:26.864Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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 }] } }
```