dotprop
v2.0.0
Published
Get property value by dot notation
Downloads
17,908
Readme
dotprop ![test](https://github.com/dy/dotprop/actions/workflows/node.js.yml/badge.svg)
Get property by dot notation. A short and dependable implementation.
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 – the most compact alternative.
- sindresohrus/dot-prop - enables escaping
\.
at price of larger codebase. - facebookindicator/idx