Lodash utility library exported as ES6 modules for modern JavaScript applications with tree-shaking support.
npx @tessl/cli install tessl/npm-lodash-es@4.17.00
# Lodash ES
1
2
Lodash ES is the Lodash utility library exported as ES6 modules, providing 300+ utility functions for common programming tasks. It offers modular imports for better tree-shaking, enabling modern JavaScript applications to import only the specific utilities they need, reducing bundle size while maintaining the full power and consistency of the Lodash API.
3
4
## Package Information
5
6
- **Package Name**: lodash-es
7
- **Package Type**: npm
8
- **Language**: JavaScript (ES6 modules)
9
- **Installation**: `npm install lodash-es`
10
11
## Core Imports
12
13
```javascript
14
import { map, filter, reduce, cloneDeep } from "lodash-es";
15
```
16
17
You can also import individual functions:
18
19
```javascript
20
import map from "lodash-es/map.js";
21
import filter from "lodash-es/filter.js";
22
```
23
24
For category imports:
25
26
```javascript
27
import * as array from "lodash-es/array.js";
28
import * as collection from "lodash-es/collection.js";
29
```
30
31
For the complete lodash instance (not recommended for production due to bundle size):
32
33
```javascript
34
import _ from "lodash-es";
35
```
36
37
## Basic Usage
38
39
```javascript
40
import { map, filter, groupBy, cloneDeep } from "lodash-es";
41
42
const users = [
43
{ name: "Alice", age: 25, active: true, department: "engineering" },
44
{ name: "Bob", age: 30, active: false, department: "sales" },
45
{ name: "Charlie", age: 35, active: true, department: "engineering" }
46
];
47
48
// Transform data
49
const activeUserNames = map(
50
filter(users, "active"),
51
"name"
52
); // ["Alice", "Charlie"]
53
54
// Group data
55
const usersByDepartment = groupBy(users, "department");
56
/* {
57
engineering: [Alice, Charlie],
58
sales: [Bob]
59
} */
60
61
// Deep clone objects
62
const usersCopy = cloneDeep(users);
63
```
64
65
## Architecture
66
67
Lodash ES is organized around several key concepts:
68
69
- **Modular Design**: Each function is available as a separate ES6 module for optimal tree-shaking
70
- **Category Organization**: Functions are grouped into logical categories (Array, Collection, Object, etc.)
71
- **Iteratee Shorthand**: Many functions support string, object, and array shorthand for iteratees
72
- **Chain Support**: Full chaining support via the main lodash instance
73
- **Type Coercion**: Consistent type handling and conversion patterns across all functions
74
75
## Capabilities
76
77
### Array Manipulation
78
79
Comprehensive array utilities for creation, modification, and analysis including chunking, flattening, set operations, and element manipulation.
80
81
```javascript { .api }
82
function chunk(array, size);
83
function compact(array);
84
function difference(array, ...values);
85
function drop(array, n);
86
function flatten(array);
87
function uniq(array);
88
```
89
90
[Array Functions](./array.md)
91
92
### Collection Operations
93
94
Iteration and transformation utilities that work with arrays, objects, and other collections, including mapping, filtering, reducing, and grouping operations.
95
96
```javascript { .api }
97
function map(collection, iteratee);
98
function filter(collection, predicate);
99
function reduce(collection, iteratee, accumulator);
100
function groupBy(collection, iteratee);
101
function every(collection, predicate);
102
function some(collection, predicate);
103
```
104
105
[Collection Functions](./collection.md)
106
107
### Object Utilities
108
109
Object manipulation functions for property access, modification, merging, and transformation including deep operations and property path handling.
110
111
```javascript { .api }
112
function get(object, path, defaultValue);
113
function set(object, path, value);
114
function merge(object, ...sources);
115
function pick(object, ...paths);
116
function omit(object, ...paths);
117
function keys(object);
118
```
119
120
[Object Functions](./object.md)
121
122
### String Processing
123
124
String manipulation utilities for case conversion, trimming, templating, and text processing operations.
125
126
```javascript { .api }
127
function camelCase(string);
128
function kebabCase(string);
129
function snakeCase(string);
130
function capitalize(string);
131
function trim(string, chars);
132
function template(string, options);
133
```
134
135
[String Functions](./string.md)
136
137
### Function Utilities
138
139
Function composition, decoration, and control flow utilities including debouncing, throttling, currying, and memoization.
140
141
```javascript { .api }
142
function debounce(func, wait, options);
143
function throttle(func, wait, options);
144
function curry(func, arity);
145
function memoize(func, resolver);
146
function bind(func, thisArg, ...partials);
147
function once(func);
148
```
149
150
[Function Functions](./function.md)
151
152
### Type Checking
153
154
Comprehensive type checking utilities for validating data types, including primitives, objects, arrays, and special types.
155
156
```javascript { .api }
157
function isArray(value);
158
function isObject(value);
159
function isString(value);
160
function isNumber(value);
161
function isFunction(value);
162
function isEmpty(value);
163
```
164
165
[Type Checking Functions](./lang.md)
166
167
### Mathematical Operations
168
169
Mathematical utilities for arithmetic operations, rounding, and statistical calculations.
170
171
```javascript { .api }
172
function add(augend, addend);
173
function subtract(minuend, subtrahend);
174
function multiply(multiplier, multiplicand);
175
function divide(dividend, divisor);
176
function sum(array);
177
function mean(array);
178
```
179
180
[Math Functions](./math.md)
181
182
### Number Utilities
183
184
Number manipulation utilities for clamping, range checking, and random number generation.
185
186
```javascript { .api }
187
function clamp(number, lower, upper);
188
function inRange(number, start, end);
189
function random(lower, upper, floating);
190
```
191
192
[Number Functions](./number.md)
193
194
### Utility Functions
195
196
General utility functions for common programming patterns including identity, constant functions, flow control, and stub functions.
197
198
```javascript { .api }
199
function identity(value);
200
function constant(value);
201
function noop();
202
function flow(...funcs);
203
function times(n, iteratee);
204
function uniqueId(prefix);
205
```
206
207
[Utility Functions](./util.md)
208
209
### Sequence/Chain Operations
210
211
Chain operations that enable method chaining and lazy evaluation for complex data transformation pipelines.
212
213
```javascript { .api }
214
function chain(value);
215
```
216
217
[Sequence Functions](./seq.md)
218
219
### Date Operations
220
221
Date and time utilities for timestamp operations.
222
223
```javascript { .api }
224
function now();
225
```
226
227
[Date Functions](./date.md)
228
229
## Common Patterns
230
231
### Iteratee Shorthand
232
233
Many lodash functions accept iteratee shorthand:
234
235
```javascript
236
// Function iteratee
237
map(users, user => user.name);
238
239
// Property string shorthand
240
map(users, 'name');
241
242
// Object match shorthand
243
filter(users, { active: true });
244
245
// Property-value pair shorthand
246
filter(users, ['active', true]);
247
```
248
249
### Chaining
250
251
```javascript
252
import _ from "lodash-es";
253
254
const result = _(users)
255
.filter('active')
256
.map('name')
257
.sort()
258
.value();
259
```
260
261
### Error Handling
262
263
- Invalid iteratees default to identity function
264
- Invalid paths return `undefined`
265
- Type checking functions return `false` for invalid types
266
- Math functions may return `NaN` for invalid inputs
267
268
## Performance Notes
269
270
- Use named imports for better tree-shaking: `import { map } from "lodash-es"`
271
- Individual function imports minimize bundle size: `import map from "lodash-es/map.js"`
272
- Functions are optimized for both performance and memory usage
273
- Chain operations support lazy evaluation for better performance