Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fast-get

queicherius1.3kMIT1.0.5

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

object, get, path

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