Giter Site home page Giter Site logo

lodash-deep's Introduction

lodash-deep

Lodash mixins for (deep) object accessing / manipulation.

Bower version NPM version Build Status Sauce Test Status Dependency Status

Version 2.x

In 2.0 most of the methods of this module where removed, because Lodash now supports their functionality natively. E.g.:

_.deepGet(object, 'father.name');
// ->
_.get(object, 'father.name');

_.deepPluck(array, 'father.name');
// ->
_.map(array, 'father.name');

Compatibility

lodash-deep is currently compatible with:

  • Node.js
  • All ES5 compatible browsers (IE9+, Chrome, Firefox, Safari etc)

Installation

Bower

  1. bower install lodash-deep
  2. Reference lodash-deep.min.js after lodash.min.js

Node.js

  1. npm install lodash
  2. npm install lodash-deep
  3. var _ = require("lodash");
    _.mixin(require("lodash-deep"));

Docs

The following mixins are included in lodash-deep:

_.deepMapValues(object, propertyPath)

Maps all values in an object tree and returns a new object with the same structure as the original.

object

Type: Object

The root object of the object tree.

callback

Type: Function

The function to be called per iteration on any non-object value in the tree.

Callback is invoked with 2 arguments: (value, path).

value the value of the current property.

path the path of the current property.

returns

Type: Object

var object = {
    level1: {
        value: 'value 1'
        level2: {
            value: 'value 2'
            level3: {
                value: 'value 3'
            }
        }
    }
};

_.deepMapValues(object, function(value, path){
    return path + ' is ' + value)
});

/** ->
 *    {
 *        level1: {
 *            value: 'level1.value is value 1'
 *            level2: {
 *                value: 'level1.level2.value is value 2'
 *                level3: {
 *                    value: 'level1.level2.level3.value is value 3'
 *                }
 *            }
 *        }
 *    };
 */

Contributing

Please use the canary branch when creating a pull request.

Contributors

lodash-deep's People

Contributors

andrewluetgers avatar beaugunderson avatar james1x0 avatar markalfred avatar spenceralger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.