Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
A utility library delivering consistency, customization, performance, and extras.
Lodash is a JavaScript library that provides utility functions for common programming tasks using a functional programming paradigm. It includes functions for manipulating and traversing arrays, objects, and strings, as well as utilities for functions, language, math, number, object, sequence, and utility methods.
Array Manipulation
Lodash provides a rich set of array manipulation functions such as map, filter, find, and sort. The code sample demonstrates sorting an array in ascending order using a custom comparator.
[3, 2, 1].sort(_.compareWith(function(a, b) { return a - b; }))
Object Manipulation
Lodash allows for easy manipulation and traversal of objects. The code sample shows how to assign properties from source objects to a destination object.
_.assign({ 'a': 1 }, { 'b': 2 }, { 'c': 3 })
String Manipulation
Lodash includes functions to manipulate strings, such as converting to different cases, trimming, padding, etc. The code sample demonstrates converting a string to kebab-case.
_.kebabCase('Foo Bar')
Function Utilities
Lodash provides function utilities like debounce and throttle to control function invocation. The code sample shows a debounced function that will only be invoked after 250 milliseconds have passed without it being called again.
_.debounce(function() { console.log('Debounced'); }, 250)
Language Utilities
Lodash includes utilities for deep cloning, merging, and comparing objects. The code sample demonstrates deep cloning an object to ensure nested objects are cloned as well.
_.cloneDeep({ 'a': 1, 'b': { 'c': 2 } })
Underscore is a utility library with similar functionality to Lodash, offering a range of functions for manipulating arrays, objects, and functions. It is generally considered to be the predecessor to Lodash, which provides a superset of Underscore's features with additional performance optimizations.
Ramda is a functional programming library that emphasizes a more functional and composable approach compared to Lodash. It provides similar utilities but focuses on immutability and side-effect free functions, which can lead to a different programming style.
Immutable.js offers a different take on data manipulation by providing persistent immutable data structures. Unlike Lodash, which works with standard JavaScript objects and arrays, Immutable.js uses its own data structures, which can lead to better performance and easier reasoning about state changes in certain applications.
A utility library delivering consistency, customization, performance, & extras.
Lo-Dash builds (for modern environments):
Development and
Production
Lo-Dash compatibility builds (for legacy and modern environments):
Development and
Production
Underscore compatibility builds:
Development and
Production
CDN copies of ≤ v1.3.1’s builds are available on cdnjs thanks to CloudFlare:
Lo-Dash dev,
Lo-Dash prod,
Lo-Dash compat-dev,
Lo-Dash compat-prod,
Underscore compat-dev, and
Underscore compat-prod
For optimal file size, create a custom build with only the features you need
We’ve got API docs, benchmarks, and unit tests.
For a list of upcoming features, check out our roadmap.
fromIndex
argumentoptions
argument for more controlObject
constructorthis
bindingcallback
and thisArg
argumentscallback
shorthandsFor more information check out these articles, screencasts, and other videos over Lo-Dash:
Lo-Dash has been tested in at least Chrome 527, Firefox 221, IE 6-10, Opera 9.25~12, Safari 3-6, Node.js 0.4.8-0.10.7 (Node bug #5622 prevents 0.10.8-0.10.10 from working), Narwhal 0.3.2, PhantomJS 1.9.0, RingoJS 0.9, and Rhino 1.7RC5.
In browsers:
<script src="lodash.js"></script>
Using npm
:
npm install lodash
npm install -g lodash
npm link lodash
To avoid potential issues, update npm
before installing Lo-Dash:
npm install npm -g
In Node.js and RingoJS ≥ v0.8.0:
var _ = require('lodash');
// or as a drop-in replacement for Underscore
var _ = require('lodash/dist/lodash.underscore');
Note: If Lo-Dash is installed globally, run npm link lodash
in your project’s root directory before requiring it.
In RingoJS ≤ v0.7.0:
var _ = require('lodash')._;
In Rhino:
load('lodash.js');
In an AMD loader like RequireJS:
require({
'paths': {
'underscore': 'path/to/lodash'
}
},
['underscore'], function(_) {
console.log(_.VERSION);
});
cache
property to the objects returned by getObject
maxWait
unit tests pass in RingomaxPoolSize
valuereleaseArray
and releaseObject
_.transform
method_.chain
and _.findWhere
aliasesmaxWait
option to _.debounce
_.random
component build
lodash
and underscore
build methodsleading
and trailing
options, works as expectedfalse
in _.isObject
and _.isRegExp
_.clone
, _.flatten
, and _.uniq
can be used as a callback
for methods like _.map
_.forIn
works on objects with longer inheritance chains in IE < 9_.isPlainObject
returns true
for empty objects in IE < 9_.max
and _.min
chain correctlyclearTimeout
use doesn’t cause errors in Titanium--stdout
build option doesn't write to a filecache
Error.prototype
iteration bugs_.indexOf
template
pre-compiler build option avoid escaping non-ascii characters_.createCallback
avoid binding functions if they don’t reference this
_.difference
, _.intersection
, and _.uniq
_.flatten
and _.indexOf
use_.unzip
and _.zip
_.assign
and _.defaults
The full changelog is available here.
Lo-Dash is part of the BestieJS “Best in Class” module collection. This means we promote solid browser/environment support, ES5+ precedents, unit testing, and plenty of documentation.
John-David Dalton |
Blaine Bublitz | Kit Cambridge | Mathias Bynens |
FAQs
Lodash modular utilities.
The npm package lodash receives a total of 33,824,185 weekly downloads. As such, lodash popularity was classified as popular.
We found that lodash demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.