o.set
fast { property: 'setter' }
Last updated 2 years ago by zewish .
BSD-2-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install o.set 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.6                                ...           latest (2 years ago)

7 Versions

  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 0
Last Month 11
Dependencies (0)
None
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |