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 🙏

© 2025 – Pkg Stats / Ryan Hefner

deeper-lodash

v0.0.5

Published

递归处理数据

Readme

deeper-lodash

概述:

递归处理数据,有时我们需要递归地从对象或者数组中处理某些数据。
deeper-lodash 解决了这个问题并仅使用 lodash 作为外部依赖项。 deeper-lodash 使用了 Vite 作为打包构建工具。而最终构建的浏览器兼容目标,使用的是Vite 特有的值:modules,这是指支持原生 ES 模块、原生 ESM 动态导入 和 import.meta 的浏览器。Vite 将替换 modules['es2020', 'edge88', 'firefox78', 'chrome87', 'safari14']

特征:

  • 支持 ESM、CommonJS、CDN 三种导入方式
  • 递归匹配 value 从数据中排除
  • 递归匹配 key 从数据中排除
  • 递归的将数据中的空值排除

使用:

nodejs 项目中使用:

  • 安装:
npm install deeper-lodash
  • ES6 Module:
import { deepOmitNil } from 'deeper-lodash';
deepOmitNil({ name: 'loclink', age: 18, aaa: undefined, bbb: null, ccc: NaN });
  • CommonJS:
// 递归过滤空值
const { deepOmitNil } = require('deeper-lodash');
deepOmitNil({ name: 'loclink', age: 18, aaa: undefined, bbb: null, ccc: NaN });

CDN 方式使用:

  • CDN 方式中所有成员变量都可以在_DL命名空间下被使用。
  • 但 lodash 作为本项目的外部依赖库,所以在使用此方式导入时,lodash 不能像在 nodejs 项目中那样读取依赖并自动安装至项目,所以你还需要手动引入 lodash 确保并确保命名空间:_ 存在且是正常工作的。
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/deeper-lodash/dist/index.min.js"></script>
    <script>
      _DL.deepOmitNil({
        name: 'loclink',
        age: 18,
        aaa: undefined,
        bbb: null,
        ccc: NaN
      });
    </script>
  </body>
</html>

deepOmitNil:

  • summary:
    递归过滤空值

  • params:

    • data:
      • type: Array | PlainObject
      • summary:
        数组或普通对象,即由对象构造函数创建的对象还是具有原型为空的对象。
    import { deepOmitNil } from 'deeper-lodash';
    deepOmitNil({
      name: 'loclink',
      age: 18,
      aaa: undefined,
      bbb: null,
      ccc: NaN,
      ddd: [
        undefined,
        {
          name: 'qwe'
        }
      ]
    });
    // => {
    //     "name": "loclink",
    //     "age": 18,
    //     "ddd": [
    //         {
    //             "name": "qwe"
    //         }
    //     ]
    //   }

deepOmitByValues

  • summary:
    递归匹配 value 过滤

  • params:

    • data:
      • type: Array | PlainObject
      • summary:
        数组或普通对象,即由对象构造函数创建的对象还是具有原型为空的对象。
    • props:
      • type: (string | number | boolean | undefined | null)[]
      • summary:
        需要过滤的值
    import { deepOmitByValues } from 'deeper-lodash';
    deepOmitByValues(
      {
        name: 'loclink',
        age: 18,
        aaa: undefined,
        bbb: null,
        ccc: NaN,
        ddd: [
          undefined,
          {
            name: 'qwe'
          }
        ]
      },
      ['qwe', 18]
    );
    
    /**
     *
     => {
        name: 'loclink',
        aaa: undefined,
        bbb: null,
        ccc: NaN,
        ddd: [
          undefined,
          {}
        ]
      }
    *
    */

deepOmitByKeys

  • summary:
    递归匹配 key 过滤

  • params:

    • data:
      • type: Array | PlainObject
      • summary:
        数组或普通对象,即由对象构造函数创建的对象还是具有原型为空的对象。
    • props:
      • type: string[]
      • summary:
        需要过滤的值
    import { deepOmitByKeys } from 'deeper-lodash';
    deepOmitByKeys(
      {
        name: 'loclink',
        age: 18,
        aaa: undefined,
        bbb: null,
        ccc: NaN,
        ddd: [
          undefined,
          {
            name: 'qwe'
          }
        ]
      },
      ['name', 'aaa']
    );
    
    /**
     *
     =>  {
        age: 18,
        bbb: null,
        ccc: NaN,
        ddd: [
          undefined,
          {}
        ]
      }
    *
    */