https://github.com/dy/dotprop
Get property value by string dot notation
https://github.com/dy/dotprop
Last synced: 9 months ago
JSON representation
Get property value by string dot notation
- Host: GitHub
- URL: https://github.com/dy/dotprop
- Owner: dy
- License: mit
- Created: 2014-12-08T09:56:52.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-06-20T18:13:14.000Z (almost 2 years ago)
- Last Synced: 2025-08-18T05:28:01.883Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 18.6 KB
- Stars: 15
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# dotprop [](https://github.com/dy/dotprop/actions/workflows/node.js.yml)
Get property by dot notation.
A short and dependable implementation.
```js
import getProp from 'dotprop';
getProp({a: { b: { c: 1}} }, 'a.b.c') // 1
getProp([1,2,3], 2) // 3
getProp({}, 'a.b') // undefined
// recognizes arrays too
getProp({a: { b: { c: 1}} }, ['a', 'b', 'c']) // 1
getProp({a: { 'b.c': 1 }}, ['a', 'b.c']) // 1
```
## Similar
* [developit/dlv](https://github.com/developit/dlv) – the most compact alternative.
* [sindresohrus/dot-prop](https://github.com/sindresorhus/dot-prop) - enables escaping `\.` at price of larger codebase.
* [facebookindicator/idx](https://github.com/facebookincubator/idx)
[](https://nodei.co/npm/dotprop/)