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

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

Awesome Lists containing this project

README

          

# dotprop [![test](https://github.com/dy/dotprop/actions/workflows/node.js.yml/badge.svg)](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)

[![NPM](https://nodei.co/npm/dotprop.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/dotprop/)

🕉