fast-get

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

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
fast-get
311.0.54 years ago6 years agoMinified + gzip package size for fast-get in KB

Readme

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 (array) | Performance (string) | |------------|----------------------|---------------------|----------------------| | fast-get | 220 bytes | 612,000 ops/sec | 571,000 ops/sec | | lodash.get | 2,145 bytes | 810,000 ops/sec | 200,000 ops/sec |

Licence

MIT