1.1.1 • Published 11 months ago

getv v1.1.1

Weekly downloads
3
License
ISC
Repository
-
Last release
11 months ago

getv

Get a value from an object by its path.

Intro

Not only getv is a drop-in replacement of lodash.get method, but it does it twice as fast (check benchmark.js file) and also takes half of its size.

Installation

  • npm - npm i getv -S

Usage

const getv = require('getv');

const object = {
  foo: {
    bar: 1,
  },
  baz: 5,
  lor: ['mir', 'dal'],
  boo: [
    { id: 1 },
    { id: 2 },
  ],
};

getv(object, 'none.bar');             // => undefined

getv(object, 'none.bar', 'default');  // => 'default'

getv(object, 'baz');                  // => 5

getv(object, 'foo.bar');              // => 1

getv(object, 'lor.1');                // => 'dal'

getv(object, 'boo.id');                // => [1, 2]
1.1.1

11 months ago

1.1.0

11 months ago

1.0.8

2 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

5 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago