Skip to content
fast { property: 'setter' }
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
oset.es.js
oset.js
oset.umd.js
package-lock.json
package.json
rollup.config.js
test.js

README.md

o.set

fast { property: 'setter' }

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.set 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 setter.

Usage

'use strict';

let oset = require('o.set');

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

oset(obj, 'due.a.0', 'yay'); // obj.due.a = [ 'yay' ]
oset(obj, 'due.a.1', 'horray'); // obj.due.a = [ 'yay', 'horray' ]

oset(obj, 'due.b[0][0][0]', 'super'); // obj.due.b = [ [ [ 'super' ] ] ]
oset(obj, 'due.b[0][0][1]', 'cool'); // obj.due.b = [ [ [ 'super', 'cool' ] ] ]

oset(obj, 'uno.na.not.existent', 'define me!'); // obj.uno = { na: { not: { existent: 'define me!' } } }

Install (NPM)

$ npm install --save o.set

Install (Bower)

$ bower install --save o.set

Test

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