Netherworld's Pretend Minibar

    deepnested

    2.0.2 • Public • Published

    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

    Keywords

    none

    Install

    npm i deepnested

    DownloadsWeekly Downloads

    1

    Version

    2.0.2

    License

    ISC

    Unpacked Size

    5.35 kB

    Total Files

    5

    Last publish

    Collaborators

    • tjcafferkey