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

https://github.com/shimohq/resolve-keypath

Resolve the value of an object according the keypath
https://github.com/shimohq/resolve-keypath

Last synced: 6 months ago
JSON representation

Resolve the value of an object according the keypath

Awesome Lists containing this project

README

          

# resolve-keypath

[![Build Status](https://travis-ci.org/shimohq/resolve-keypath.svg?branch=master)](https://travis-ci.org/shimohq/resolve-keypath)

## Install

```
npm install resolve-keypath
```

## Usage

```javascript
var resolve = require('resolve-keypath');

resolve({ a: { b: 1 } }, 'a.b') // 1
resolve({ a: { b: 1 } }, 'a/b', '/') // 1
resolve(null, 'a') // null

// Use `resolver` if you want to cache the result per object:
var resolver = resolve.resolver;

var myResolver = resolver({ a: { b: 1 }}, '/');
myResolver('a/b') // 1
```

# License

MIT