2.0.2 • Published 6 years ago

deepnested v2.0.2

Weekly downloads
9
License
ISC
Repository
github
Last release
6 years ago

This is a simple JavaScript function which allows you to get and set deeply nested values from objects.

npm install deepnested

Usage

import nested from 'deepnested';

Now that nested has been imported in to your project you're able to start getting and settings deeply nested object values

Get Values

var team = {
    tom: {
        name: 'Tom',
        age: 26,
        position: 'Developer',
        team: {
            title: 'Product Page',
            members: ['nick', 'tom', 'nicole'],
            employed: true
        }
    },

    nicole: {
        name: 'Nicole',
        age: 21,
        position: 'Tester'
    },

    nick: {
        name: 'Nick',
        age: 400,
        position: 'Colour-inner'
    }
};

var teamTitle = nested(team).get(['tom', 'team', 'title']); // Product Page

Set Values

You can use nested to overwrite values in your object

nested(team).set(['tom', 'team', 'employed'], false);
var employed = nested(team).get(['tom', 'team', 'employed']); // Now equal to false
2.0.2

6 years ago

2.0.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago