Skip to content
fast { property: 'getter' }
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmark
src
.gitignore
README.md
bower.json
oget.es.js
oget.js
oget.umd.js
package-lock.json
package.json
rollup.config.js
test.js

README.md

oget

fast { property: 'getter' }

How fast is it

Well, I didn't do any extensive testing on all available browsers, but since it uses only builtin functions it should be quite fast. According to this little benchmark it is currently faster than lodash.get on the current LTS version of node.js.

What this is not

This will never be some kind of "wannabe" lodash killer library. It's just what you see - a simple object property getter.

Usage

'use strict';

let oget = require('oget');

let obj = {
    uno: 1
    , due: {
        a: ['abracadabra']
        , b: [ [ [ 'horray' ] ] ]
    }
    , tre: 3
};

oget(obj, 'due.a.0'); // abracadabra
oget(obj, '[due][a[0]]'); // abracadabra
oget(obj, 'due.a[0]'); // abracadabra

oget(obj, 'due.b[0][0][0]'); // horray
oget(obj, 'due.b.0.0.0'); // horray
oget(obj, 'due[b].0[0].0'); // horray

oget(obj, 'due.b.0.0[0].missing', 'default_value!'); // default_value!

Install (NPM)

$ npm install --save oget

Install (Bower)

$ bower install --save oget

Test

$ npm install && npm test
You can’t perform that action at this time.