4 Star 0 Fork 0

Gitee 极速下载 / nodash

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/eBay/nodash
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

nodash

Replacement for subset of lodash, with fraction of the size.

Installation

npm i @ebay/nodash

Usage

Simply replace lodash with @ebay/nodash

const get = require('lodash/get');

// becomes

const get = require('@ebay/nodash/get');

Why?

Often, consumers of lodash use just a handful of the methods. Lodash makes this convenient by only requiring what you need:

const get = require('lodash/get'); // or require('lodash.get') if installed

However, Lodash is optimized as an entire library, which is to say it makes heavy reuse of its own methods. So using get may require baseGet, which requires castPath and toKey, which then requires isKey, stringToPath, and isSymbol... and so forth. It keeps going for many more levels.

This ends up with a bundle size of over 7kb just for using get. While that becomes cheaper the more you use Lodash, if all you use is get, it remains quite expensive. The Nodash version of the same method weighs in at ~500b for comparison.

As such, this library is targeted for just those users that need a small subset of Lodash, and not the whole library. It is not intended to be a replacement for Lodash.

Methods

Most methods are identical to Lodash. Some methods have partial support, to shed off edge cases for the sake of saving size. The API for all are otherwise identical to Lodash and can be a drop-in replacement in most cases.

Name Same as Lodash? Notes
get yes get(obj, 'path.to[0].value', defaultValue)
set yes set(obj, 'path.to[0].value', value)
has yes has(obj, 'path.to[0].value')
cloneDeep yes cloneDeep(obj)
castArray yes castArray(value)
isEmpty no does not support TypedArray or Buffers. isEmpty(value)
isEqual no only does shallow comparison
partial yes partial(func, param1, param2)
partialRight yes partialRight(func, param1, param2)
throttle no does not support trailing call throttle(func, 200)

License

Copyright 2018-2019 eBay Inc.
Author/Developer: Scott Davis

Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.

Third Party Code Attribution and Licenses

This software contains code licensed by third parties. In particular, see : https://github.com/lodash/lodash/blob/master/LICENSE

Copyright JS Foundation and other contributors https://js.foundation/

Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/

This software consists of voluntary contributions made by many individuals. For exact contribution history, see the revision history available at https://github.com/lodash/lodash

空文件

简介

nodash 是 Lodash子集的轻量级替换,由 eBay 开源 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/mirrors/nodash.git
git@gitee.com:mirrors/nodash.git
mirrors
nodash
nodash
master

搜索帮助