Neoclassical Programming Multitude

npm

Need private packages and team management tools?Check out npm Orgs. »

dotaccess

1.0.5 • Public • Published

dotaccess Build Status

A library to access objects using dot notation strings. For example:

var dotaccess = require('dotaccess')
var obj = {
  answer: 42,
  deep: {
    trench: 43,
    'funky names': 44,
    'including a .': 45
  }
}
 
// prints 42
console.log(dotaccess.get(obj, 'answer'))
 
// prints 43
console.log(dotaccess.get(obj, 'deep.trench'))
 
// can use an array of part names also prints 43
console.log(dotaccess.get(obj, ['deep', 'trench']))
 
// prints 44, spaces are allowed
console.log(dotaccess.get(obj, 'deep.funky names'))
 
// overwrite existing values
dotaccess.set(obj, 'deep.funky names', 99, true)
 
// can also set stuff
dotaccess.set(obj, 'deep.an even funkier_name', 'green')

Keywords

none

install

npm i dotaccess

Downloadsweekly downloads

88

version

1.0.5

license

none

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability