Skip to content

KoryNunn/unbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
        }
    }
}

About

get/set/etc into objs via an array of keys

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages