Immutable arrays with functional operations
Transform collections with map, filter, reduce without mutating the original data
List is an immutable collection that wraps arrays and provides functional operations. Every transformation creates a new List, preserving the original data.
const numbers = List([1, 2, 3, 4])
// Transform
const doubled = numbers.map((n) => n * 2) // List([2, 4, 6, 8])
// Filter
const evens = numbers.filter((n) => n % 2 === 0) // List([2, 4])
// Reduce
const sum = numbers.reduce((acc, n) => acc + n, 0) // 10
// Chain operations - take first 2 after transformations
const result = numbers
.filter((n) => n > 1)
.map((n) => n * 2)
.toArray()
.slice(0, 2) // [4, 6] - using array slice instead of take
// Convert back to array
const array = result // [4, 6] - result is already an array
All operations return new Lists - original data never changes
12x faster than nested flatMaps for complex operations
map, filter, fold, groupBy, and 40+ more operations
Full TypeScript inference for all transformations
const numbers = List([1, 2, 3, 4, 5])
const empty = List<number>([])
const range = List([...Array(5).keys()]) // List([0, 1, 2, 3, 4])
const numbers = List([1, 2, 3, 4])
const result = numbers
.filter((n) => n > 1)
.map((n) => n * 2)
.reduce((acc, n) => acc + n, 0) // 18
const pairs = List([1, 2, 3]).flatMap((x) => List([x, x * 10]))
// List([1, 10, 2, 20, 3, 30])
UI state, user inputs, historical data
Data processing, analytics, transformations
Generating combinations, test data, permutations