npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@agostone/lodash-deeps

v0.3.0

Published

Lodash deep mixin pairs for functions that has none.

Downloads

9

Readme

lodash-deeps

Lodash 'deep' mixin pairs for functions that has none.

Compatibility

lodash-deeps is currently compatible with:

  • Node.js (>=8.9.*)
  • ES6 compatible browsers

Might work with lower node versions, haven't tested.

Browser wise, ONLY tested with chrome.

Installation

Bower?

No bower package yet, but the npm package has a browser version in dist directory.

  1. copy dist/lodash-deeps.min.js to your frontend js directory or use a bundler
  2. Reference lodash-deeps.min.js after lodash.min.js

Node.js

  1. npm install lodash
  2. npm install @agostone/lodash-deeps
  3. 
    const _ = require("lodash");
    _.mixin(require("@agostone/lodash-deeps"));

Docs

The following mixins are included in lodash-deeps:

_.compactDeep(array)

This method is like _.compact except that it recursively compacts nested arrays too.

_.filterDeep(collection, predicate = _.identity)

This method is like _.filter except that it recursively filters nested collections too.

const collection = [
    {
        'color': 'blue',
        'sub': {
            'name': 'sub',
            'color': 'red'
        }
    },
    {
        'name': 'main',
        'color': 'red'
    }
];
_.filterDeep(collection, value => value.color === 'red');
/**
* ->
* [{
*   'name': 'main',
*   'color': 'red'
* }, {
*   'name': 'sub',
*   'color': 'red'
* }]
*/
}

_.findDeep(collection, predicate = _.identity, fromIndex = 0, returnRoot = true) {

This method is like _.find except that it recursively executes predicate for nested collections.

Only difference is, if returnRoot is false, it'll return the found element, if true, will return the nesting elements too, up to the root.

const source = {
    'one': 'one',
    'two': 'two',
    'three': {
        'four': {
            'five': 'five',
            'six': 'six'
        },
        'seven': 'seven'
    }
};
_.findDeep(source, value => value === 'five');
/**
* ->
* {
*     'four': {
*         'five': 'five',
*         'six': 'six'
*     },
*     'seven': 'seven'
* }
*/
_.findDeep(source, value => value === 'five', 0, false);
/**
* ->
* 'five'
*/

_.findIndexDeep(array, predicate = _.identity, fromIndex = 0) {

This method is like _.findIndex except that it recursively executes predicate for nested arrays.

Only difference is, when predicate is truthy for an element in a deeper level, the result is an index array.

const array = ['one', ['two', 'three'], 'four'];
const index = _.findIndexDeep(array, value => value === 'two');
_.get(array, index);
/**
* ->
* index == [1, 0]
* _.get == 'two'
*/

_.joinDeep(array, separator = ',')

This method is like _.join except that it recursively compacts nested arrays too.

const array = ['one', ['two', 'three'], 'four'];
_.joinDeep(array, '-');
/**
* ->
* 'one-two-three-four'
*/

_.mapKeysDeep(object, iteratee = _.identity)

This method is like _.mapKeys except that it recursively maps keys.

_.mapValuesDeep(object, iteratee = _.identity)

This method is like _.mapValues except that it recursively maps values.

_.pickByDeep(object, predicate = _.identity)

This method is like _.pickBy except that it recursively checks in nested collections too.

const source = {
    'one': 'one',
    'two': 'two',
    'three': undefined,
    'four': [
        'two', NaN, 'three'
    ],
    'six': aFunction,
    'seven': theClass,
    'eight': {
        'color': 'red'
    }
};
_.pickByDeep(source, value => value === 'red');
/**
* ->
* {
*     'eight': {
*         'color': 'red'
*     }
* } 
*/

Requests

I plan to add more deep functions when/if they are needed. Feel free to request or feel free to contribute. =)

Contributing

Please use git-flow. (git-flow cheat sheet)

Credits

  • README.md
  • gulpfile.js
  • karma.config.js

files are based on lodash-deep.

License

MIT

TODO

  • More browsers test?
  • Travis?
  • Sauce labs?