CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-lodash

A comprehensive JavaScript utility library with 296+ functions for arrays, objects, strings, and functional programming

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

Lodash

Lodash is a modern JavaScript utility library delivering modularity, performance & extras. It provides 296+ utility methods for common programming tasks using a functional programming approach, making JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, etc.

Overview

Lodash is the most popular JavaScript utility library, providing a comprehensive set of 296+ functions for common programming tasks. Built with a focus on modularity, performance, and functional programming principles, Lodash simplifies complex operations on arrays, objects, strings, functions, and other data types.

Key Features:

  • Comprehensive API: 296+ utility methods covering arrays, collections, functions, objects, strings, math, and more
  • Modular Architecture: Import individual methods or entire categories to optimize bundle size
  • Method Chaining: Fluent interface for composing complex data transformations
  • Functional Programming: /fp variant with auto-curried, iteratee-first methods
  • Performance Optimized: Heavily optimized implementations with lazy evaluation
  • Cross-platform: Works in Node.js, browsers, and other JavaScript environments
  • Type Safety: Full TypeScript definitions for complete type safety

Package Information

  • Package Name: lodash
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install lodash

Core Imports

// Full library import (UMD)
const _ = require('lodash');
// ES6 imports
import _ from 'lodash';
import { map, filter, reduce } from 'lodash';
// Individual method imports (recommended for bundle size)
const map = require('lodash/map');
const filter = require('lodash/filter');
// Category imports
const array = require('lodash/array');
const object = require('lodash/object');
// Functional programming variant
const fp = require('lodash/fp');

Browser (UMD):

<script src="lodash.js"></script>
<script>
  _.map([1, 2, 3], n => n * 2);
</script>

Basic Usage

const _ = require('lodash');

// Array operations
const numbers = [1, 2, 3, 4, 5, 6];
const evens = _.filter(numbers, n => n % 2 === 0);
const doubled = _.map(numbers, n => n * 2);
const chunks = _.chunk(numbers, 2); // [[1, 2], [3, 4], [5, 6]]

// Object manipulation
const users = [
  { name: 'Alice', age: 25, active: true },
  { name: 'Bob', age: 30, active: false },
  { name: 'Charlie', age: 35, active: true }
];

const activeUsers = _.filter(users, 'active');
const usersByAge = _.groupBy(users, 'age');
const names = _.map(users, 'name');

// String operations
const text = 'hello world';
const camelCase = _.camelCase(text); // 'helloWorld'
const kebabCase = _.kebabCase(text); // 'hello-world'

// Method chaining
const result = _(users)
  .filter('active')
  .map('name')
  .sort()
  .value(); // ['Alice', 'Charlie']

Architecture

Lodash is built around several key architectural patterns:

  • Modular Design: Every method is available as an individual module for optimal bundle sizing
  • Method Chaining: Supports both explicit chaining with _.chain() and implicit chaining with _(value)
  • Functional Programming: /fp variants provide auto-curried, iteratee-first, and composition-friendly methods
  • Performance Optimization: Heavily optimized implementations with lazy evaluation in chains
  • Type Safety: Includes TypeScript definitions for full type safety
  • Cross-platform: Works in Node.js, browsers, and other JavaScript environments

Capabilities

Array Methods

Comprehensive array manipulation utilities for chunking, flattening, filtering, and transforming arrays.

function chunk<T>(array: T[], size?: number): T[][];
function flatten<T>(array: T[] | T[][]): T[];
function uniq<T>(array: T[]): T[];
function intersection<T>(...arrays: T[][]): T[];

Array Methods

Collection Methods

Iteration and manipulation methods that work on arrays, objects, and other iterable collections.

function map<T, R>(collection: T[], iteratee: (value: T, index: number, array: T[]) => R): R[];
function filter<T>(collection: T[], predicate: (value: T, index: number, array: T[]) => boolean): T[];
function groupBy<T>(collection: T[], iteratee: string | ((value: T) => any)): { [key: string]: T[] };
function reduce<T, R>(collection: T[], iteratee: (accumulator: R, value: T, index: number, array: T[]) => R, initialValue?: R): R;

Collection Methods

Function Utilities

Function composition, currying, debouncing, throttling, and other function manipulation utilities.

function debounce<T extends (...args: any[]) => any>(func: T, wait?: number, options?: DebounceOptions): T & { cancel(): void; flush(): ReturnType<T> };
function throttle<T extends (...args: any[]) => any>(func: T, wait?: number, options?: ThrottleOptions): T & { cancel(): void; flush(): ReturnType<T> };
function curry<T extends (...args: any[]) => any>(func: T, arity?: number): CurriedFunction<T>;
function memoize<T extends (...args: any[]) => any>(func: T, resolver?: (...args: any[]) => any): T & { cache: Map<any, any> };

interface DebounceOptions {
  leading?: boolean;
  maxWait?: number;
  trailing?: boolean;
}

interface ThrottleOptions {
  leading?: boolean;
  trailing?: boolean;
}

type CurriedFunction<T> = T & {
  (...args: any[]): any;
};

Function Methods

Type Checking & Language Utilities

Comprehensive type checking predicates and value conversion utilities for JavaScript types.

function isArray(value: any): value is any[];
function isObject(value: any): value is object;
function isString(value: any): value is string;
function isFunction(value: any): value is Function;
function clone<T>(value: T): T;
function cloneDeep<T>(value: T): T;

Language Methods

Mathematical Operations

Mathematical computations including basic arithmetic, aggregation, and range utilities.

function add(augend: number, addend: number): number;
function sum(array: number[]): number;
function max(array: number[]): number | undefined;
function min(array: number[]): number | undefined;
function mean(array: number[]): number;
function range(start?: number, end?: number, step?: number): number[];

Math Methods

Object Manipulation

Deep object operations including property access, merging, transformation, and key/value manipulation.

function get(object: any, path: string | string[], defaultValue?: any): any;
function set(object: any, path: string | string[], value: any): any;
function merge<T, S>(object: T, source: S): T & S;
function omit<T, K extends keyof T>(object: T, ...paths: K[]): Omit<T, K>;
function pick<T, K extends keyof T>(object: T, ...paths: K[]): Pick<T, K>;

Object Methods

String Processing

String transformation utilities for case conversion, templating, and text manipulation.

function camelCase(string?: string): string;
function kebabCase(string?: string): string;
function capitalize(string?: string): string;
function template(string: string, options?: TemplateOptions): TemplateExecutor;
function truncate(string?: string, options?: TruncateOptions): string;

interface TemplateOptions {
  escape?: RegExp;
  evaluate?: RegExp;
  interpolate?: RegExp;
  variable?: string;
}

interface TruncateOptions {
  length?: number;
  omission?: string;
  separator?: string | RegExp;
}

type TemplateExecutor = (data?: any) => string;

String Methods

Utility Functions

General-purpose utilities including function creation, control flow, and miscellaneous helpers.

function identity<T>(value: T): T;
function noop(): void;
function constant<T>(value: T): () => T;
function times<T>(n: number, iteratee: (index: number) => T): T[];
function uniqueId(prefix?: string): string;

Utility Methods

Method Chaining

Lodash provides powerful chaining capabilities for composing operations:

// Explicit chaining
function chain<T>(value: T): LodashWrapper<T>;

// Chain methods
interface LodashWrapper<T> {
  value(): T;
  tap(interceptor: (value: T) => void): LodashWrapper<T>;
  thru<R>(interceptor: (value: T) => R): LodashWrapper<R>;
}

// Implicit chaining with _(value)
function _<T>(value: T): LodashWrapper<T>;

Constants

const VERSION: string; // "4.9.0"

interface TemplateSettings {
  escape?: RegExp;
  evaluate?: RegExp;
  interpolate?: RegExp;
  variable?: string;
}

const templateSettings: TemplateSettings;

Types

type Iteratee<T, R = any> = 
  | ((value: T, index: number, collection: T[]) => R)
  | string
  | number
  | object;

type Predicate<T> = 
  | ((value: T, index: number, collection: T[]) => boolean)
  | string
  | [string, any]
  | object;

type PropertyPath = string | number | symbol | Array<string | number | symbol>;

interface LoDashStatic {
  VERSION: string;
  templateSettings: TemplateSettings;
  
  // All lodash methods are available on the main export
  [key: string]: any;
}

interface TemplateSettings {
  escape?: RegExp;
  evaluate?: RegExp;
  interpolate?: RegExp;
  variable?: string;
}

docs

array-methods.md

collection-methods.md

function-methods.md

index.md

lang-methods.md

math-methods.md

object-methods.md

string-methods.md

util-methods.md

tile.json