A modern, tree-shakable JavaScript utility library with TypeScript support, inspired by Lodash but built for modern development.
- ๐ณ Tree-shakable: Import only what you need
- ๐ฆ Zero dependencies: Lightweight and fast
- ๐ Type-safe: Full TypeScript support with strict types
- ๐ Chainable: Optional chain API for fluent programming
- ๐ Modern: ES2018+ with native JavaScript optimizations
- ๐งช Well-tested: >90% test coverage
- ๐ Well-documented: Comprehensive docs with examples
npm install prodash
# or
yarn add prodash
# or
pnpm add prodash// Individual imports - best for tree-shaking
import map from 'prodash/map';
import filter from 'prodash/filter';
const numbers = [1, 2, 3, 4, 5];
const doubled = map(numbers, n => n * 2);
const evens = filter(doubled, n => n % 2 === 0);
console.log(evens); // [4, 8]// Named imports - good for tree-shaking
import { map, filter, debounce } from 'prodash';
const debouncedSearch = debounce(searchAPI, 300);// Fluent chain API
import { chain } from 'prodash';
const result = chain([1, 2, 3, 4, 5])
.filter(n => n % 2 === 0)
.map(n => n * 2)
.uniq()
.value();
console.log(result); // [4, 8]| Function | Description | Example |
|---|---|---|
map |
Transform array elements | map([1,2,3], x => x*2) โ [2,4,6] |
filter |
Filter array elements | filter([1,2,3,4], x => x%2===0) โ [2,4] |
uniq |
Remove duplicates | uniq([1,2,2,3]) โ [1,2,3] |
chunk |
Split into chunks | chunk([1,2,3,4], 2) โ [[1,2],[3,4]] |
| Function | Description | Example |
|---|---|---|
pick |
Select properties | pick({a:1,b:2,c:3}, ['a','c']) โ {a:1,c:3} |
omit |
Exclude properties | omit({a:1,b:2,c:3}, ['b']) โ {a:1,c:3} |
| Function | Description | Example |
|---|---|---|
debounce |
Delay function execution | debounce(fn, 300) |
| Function | Description | Example |
|---|---|---|
isEqual |
Deep equality check | isEqual([1,2], [1,2]) โ true |
cloneDeep |
Deep clone objects | cloneDeep({a: {b: 1}}) |
The chain API provides a fluent interface for composing operations:
import { chain } from 'prodash';
// Array chaining
const result = chain([1, 2, 3, 4, 5, 2, 1])
.filter(n => n > 1) // [2, 3, 4, 5, 2]
.map(n => n * 2) // [4, 6, 8, 10, 4]
.uniq() // [4, 6, 8, 10]
.take(3) // [4, 6, 8]
.value(); // Unwrap result
// Object chaining
const user = chain({ name: 'John', age: 30, email: '[email protected]' })
.pick(['name', 'email'])
.value();Prodash is designed with tree-shaking in mind. Use individual imports for the best bundle size:
// โ
Good - Only imports the map function
import map from 'prodash/map';
// โ Avoid - Imports entire library
import prodash from 'prodash';
const result = prodash.map(...);
// โ
Also good - Named imports work well with modern bundlers
import { map, filter } from 'prodash';Prodash is written in TypeScript with strict type checking:
import { map, filter } from 'prodash';
// Full type inference
const numbers: number[] = [1, 2, 3];
const strings: string[] = map(numbers, n => n.toString()); // โ
const invalid: number[] = map(numbers, n => n.toString()); // โ Type errorProdash is optimized for modern JavaScript environments:
- Uses native
Setfor deduplication (faster than nested loops) - Leverages modern JavaScript APIs when they outperform alternatives
- Benchmarked against Lodash - equal or better performance
- Minimal bundle size impact
# Install dependencies
npm install
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Build library
npm run build
# Lint code
npm run lint
# Format code
npm run formatTest prodash as a consumer would use it:
# Build prodash first
npm run build
# Go to playground
cd playground
npm install
# Run tests
npm run dev # TypeScript test
npm run test:esm # ESM import test
npm run test:cjs # CommonJS test
npm run serve # Browser testMIT ยฉ Your Name
See CONTRIBUTING.md for guidelines on how to contribute to this project.
Why Prodash?
- ๐ฏ Focused: Essential utilities without bloat
- ๐ฌ Modern: Built for ES2018+ environments
- ๐ฆ Efficient: Tree-shakable with minimal bundle impact
- ๐ก๏ธ Reliable: Comprehensive tests and TypeScript safety
- ๐ Familiar: Lodash-inspired API you already know