unbox

1.2.0 • Public • Published

unbox

Get or set values on an object from an array of keys.

Usage

has(object, pathArray/dotNotation)

var has = require('unbox/has');
 
var myObject = {
    a: {
        b: 1
    }
};
 
has(myObject, 'a.b'); // true
// OR
has(myObject, ['a', 'b']); // true
 
has(myObject, 'a.b.c'); // false

get(object, pathArray/dotNotation)

var get = require('unbox/get');
 
var myObject = {
    a: {
        b: 1
    }
};
 
get(myObject, 'a.b'); // 1
// OR
get(myObject, ['a', 'b']); // 1

set(object, pathArray/dotNotation, value)

var set = require('unbox/set');
 
set(myObject, 'a.b.c', 2);
// OR
set(myObject, ['a', 'b', 'c'], 2);

myObject will now be:

{
    a: {
        b: {
            c: 2
        }
    }
}
 

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.2.0134latest

Version History

VersionDownloads (Last 7 Days)Published
1.2.0134
1.1.52
1.1.40
1.1.30
1.1.20
1.1.10
1.1.00
1.0.10
1.0.00

Package Sidebar

Install

npm i unbox

Weekly Downloads

136

Version

1.2.0

License

MIT

Unpacked Size

7.85 kB

Total Files

8

Last publish

Collaborators

  • korynunn
  • mattlarner
  • mauricebutler