# object-resolve-path

> a simple utility function for getting a value at a path from an object with all the usecases properly covered

Latest version **1.1.1** (published 2016-04-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install object-resolve-path
pnpm add object-resolve-path
yarn add object-resolve-path
bun add object-resolve-path
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2016-04-14 |
| First published | 2015-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 66 |
| Author | capajj@gmail.com |
| Maintainers | capaj |
| Keywords | object, property, accessor, string |

## Links

- npm: https://www.npmjs.com/package/object-resolve-path
- Repository: https://github.com/capaj/object-resolve-path
- Homepage: https://github.com/capaj/object-resolve-path#readme
- Issues: https://github.com/capaj/object-resolve-path/issues
- npm.io page: https://npm.io/package/object-resolve-path

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2016-04-14
- 1.1.0 — 2015-08-04
- 1.0.0 — 2015-07-30

## README

# object-resolve-path
a simple utility function for getting a value at a path from an object with all the usecases properly covered.
Based on Path pseodoclass from https://github.com/Polymer/observe-js/blob/7e94bb14d7c44b221af7bcc874cf9898f26747d8/src/observe.js#L305

## Install
```
npm i object-resolve-path
```

## Usage

```javascript
var resolvePath = require('object-resolve-path');
resolvePath(someObject, 'a.b[0]');	//returns first property from b from a from someObject
resolvePath(someObject, 'a["b-a"][0]');	//this works as well, thanks to the parser/statemachine
```

## Typical usecase?
Most other libraries for accessing deeply nested properties of an object don't work with bracket syntax. This one does work with bracket syntax.

For thorough description, check the [tests](https://github.com/capaj/object-resolve-path/blob/master/test/object-resolve-path.spec.js).

### Similar modules:

https://www.npmjs.com/package/lodash.get (works for both but much much slower, doesn't throw when path is not valid, object-resolve-path does)

https://github.com/deoxxa/dotty (works only for dots)

https://github.com/Ntran013/dot-access  (works only for dots)

https://github.com/substack/js-traverse (much more complex and useful)


## Benchmarks

```
node benchmark.js
lodash.get x 2,088,580 ops/sec ±3.42% (74 runs sampled)
object-resolve-path x 26,260,596 ops/sec ±3.39% (85 runs sampled)
Fastest is object-resolve-path
```

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

---
_Source: https://npm.io/package/object-resolve-path · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
