darthmaim / fast-get

Gets the value at `path` of `object` (with an optional `default`)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fast-get

Build Status Coverage Status Greenkeeper badge

Gets the value at path of object (with an optional default)

Install

npm install fast-get

This module can be used for Node.js as well as browsers using Browserify.

Usage

const _get = require('fast-get')

const object = {a: [{b: {c: 3}}]}

_get(object, 'a[0].b.c')
// => 3

_get(object, ['a', '0', 'b', 'c'])
// => 3

_get(object, 'a.b.c', 'default')
// => 'default'

Tests

npm test

Benchmark

npm run benchmark
Size (uglify + gzip) Performance
fast-get 159 bytes 555,897 ops/sec
lodash.get 2,145 bytes 206,432 ops/sec

Licence

MIT

About

Gets the value at `path` of `object` (with an optional `default`)

License:MIT License


Languages

Language:JavaScript 100.0%