0.0.2 • Published 6 years ago

dotnot v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

dotnot

dotnot on Travis dotnot on NPM dotnot Downloads on NPM Standard JavaScript Style

Access object properties using dot notation.

Install

$ npm install dotnot --save

Use

import {
  get,
  set
} from 'dotnot'

const data = {
  a: {
    b: {
      c: {
        d: 1
      }
    }
  },
  e: 1
}

// get (object, path) -> value
get(data, 'a.b')             // returns { c: { d: 1 } }
get(data, 'a.b.c')           // returns { d: 1 }
get(data, 'a.b.c.d')         // returns 1
get(data, 'a.c')             // returns undefined
get(data, 'a.b.d')           // returns undefined
get(data, 'a.b.c.e')         // returns undefined

// set (object, path, value) -> value
set(data, 'a.c', 1)             // returns 1
set(data, 'a.b.d', 1)           // returns 1
set(data, 'a.b.c.e', 1)         // returns 1

License

MIT. © 2018 Michael Cavalea

0.0.2

6 years ago

0.0.1

6 years ago