- Spec files
npm-lodash
Describes: pkg:npm/lodash@4.5.x
- Description
- Comprehensive JavaScript utility library with 300+ methods for arrays, objects, strings, functions, and more.
- Author
- tessl
- Last updated
index.md docs/
1# Lodash23Lodash is a comprehensive JavaScript utility library that makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, and more. With over 300 utility methods, Lodash provides modular, high-performance solutions for common programming tasks and supports both imperative and functional programming paradigms.45## Package Information67- **Package Name**: lodash8- **Package Type**: npm9- **Language**: JavaScript10- **Installation**: `npm install lodash`1112## Core Imports1314```javascript15import _ from "lodash";16// or17import { map, filter, get } from "lodash";18```1920For CommonJS:2122```javascript23const _ = require("lodash");24// or25const { map, filter, get } = require("lodash");26```2728For functional programming style:2930```javascript31import fp from "lodash/fp";32// or33import { map, filter, get } from "lodash/fp";34```3536## Basic Usage3738```javascript39import { map, filter, get, groupBy } from "lodash";4041// Working with arrays42const numbers = [1, 2, 3, 4, 5];43const doubled = map(numbers, n => n * 2);44const evens = filter(numbers, n => n % 2 === 0);4546// Working with objects47const user = { name: 'John', profile: { age: 30 } };48const age = get(user, 'profile.age', 0);4950// Working with collections51const users = [52{ name: 'John', role: 'admin' },53{ name: 'Jane', role: 'user' },54{ name: 'Bob', role: 'admin' }55];56const byRole = groupBy(users, 'role');57```5859## Architecture6061Lodash is organized around several key design principles:6263- **Modular Design**: Each method can be imported individually for optimal bundle size64- **Multiple Build Formats**: Full build (~21kB), core build (~4kB), and per-method packages65- **Functional Programming Support**: FP variants with curried, data-last argument order66- **Performance Optimized**: Highly optimized implementations for common operations67- **Cross-Platform**: Works in browsers, Node.js, and other JavaScript environments6869## Capabilities7071### Array Manipulation7273Comprehensive utilities for working with arrays including transformation, filtering, grouping, and set operations.7475```javascript { .api }76function chunk(array, size = 1);77function compact(array);78function concat(array, ...values);79function difference(array, ...values);80function flatten(array);81function uniq(array);82function zip(...arrays);83```8485[Array Methods](./array-methods.md)8687### Collection Processing8889Powerful iteration and transformation methods that work with arrays, objects, and other collections.9091```javascript { .api }92function map(collection, iteratee);93function filter(collection, predicate);94function find(collection, predicate, fromIndex = 0);95function forEach(collection, iteratee);96function groupBy(collection, iteratee);97function reduce(collection, iteratee, accumulator);98function sortBy(collection, ...iteratees);99```100101[Collection Methods](./collection-methods.md)102103### Object Utilities104105Deep object manipulation including property access, merging, transformation, and introspection.106107```javascript { .api }108function get(object, path, defaultValue);109function set(object, path, value);110function merge(object, ...sources);111function omit(object, ...paths);112function pick(object, ...paths);113function keys(object);114```115116[Object Methods](./object-methods.md)117118### String Processing119120String manipulation utilities for case conversion, formatting, templating, and parsing.121122```javascript { .api }123function camelCase(string);124function kebabCase(string);125function capitalize(string);126function template(string, options);127function trim(string, chars = whitespace);128function truncate(string, options);129```130131[String Methods](./string-methods.md)132133### Function Enhancement134135Function composition, currying, throttling, debouncing, and other functional programming utilities.136137```javascript { .api }138function debounce(func, wait = 0, options);139function throttle(func, wait = 0, options);140function curry(func, arity = func.length);141function memoize(func, resolver);142function once(func);143function partial(func, ...partials);144```145146[Function Methods](./function-methods.md)147148### Type Checking & Validation149150Comprehensive type checking utilities for determining data types and validating values.151152```javascript { .api }153function isArray(value);154function isObject(value);155function isString(value);156function isFunction(value);157function isEmpty(value);158function isEqual(value, other);159```160161[Type Checking](./type-checking.md)162163### Mathematical Operations164165Mathematical utilities for arithmetic, aggregation, and numerical processing.166167```javascript { .api }168function add(augend, addend);169function sum(array);170function mean(array);171function max(array);172function min(array);173function clamp(number, lower, upper);174```175176[Math & Number Methods](./math-number-methods.md)177178### Utility Functions179180General-purpose utilities including flow control, constant generation, and identity functions.181182```javascript { .api }183function identity(value);184function noop();185function constant(value);186function times(n, iteratee);187function uniqueId(prefix = '');188function flow(...funcs);189function chain(value);190```191192[Utility Methods](./utility-methods.md)193194## Core Types195196```javascript { .api }197// Lodash main interface (when using default import)198interface LoDashStatic {199// All methods are available as properties200// Examples:201map: typeof map;202filter: typeof filter;203get: typeof get;204// ... 300+ more methods205}206207// Iteratee types - functions used for transformation/filtering208type Iteratee<T> = string | number | symbol | object | ((value: T) => any);209210// Property paths for object access211type PropertyPath = string | number | symbol | Array<string | number | symbol>;212213// Common callback function signatures214type ListIterator<T, TResult> = (value: T, index: number, collection: T[]) => TResult;215type ObjectIterator<TObject, TResult> = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult;216```