Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

unbox

KoryNunn632MIT1.2.0

Get or set values on an object from a a dot notated string or an array of keys.

readme

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