Thanks to visit codestin.com
Credit goes to github.com

Skip to content

huytuchim789/prodash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

48 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Prodash

A modern, tree-shakable JavaScript utility library with TypeScript support, inspired by Lodash but built for modern development.

npm version Build Status Coverage Status Bundle Size

โœจ Features

  • ๐ŸŒณ 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

๐Ÿ“ฆ Installation

npm install prodash
# or
yarn add prodash
# or
pnpm add prodash

๐Ÿš€ Quick Start

Tree-shaking friendly imports (recommended)

// 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

// Named imports - good for tree-shaking
import { map, filter, debounce } from 'prodash';

const debouncedSearch = debounce(searchAPI, 300);

Chain API

// 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]

๐Ÿ“– API Reference

Array Methods

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]]

Object Methods

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 Utilities

Function Description Example
debounce Delay function execution debounce(fn, 300)

Language Utilities

Function Description Example
isEqual Deep equality check isEqual([1,2], [1,2]) โ†’ true
cloneDeep Deep clone objects cloneDeep({a: {b: 1}})

๐Ÿ”— Chain API

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();

๐ŸŒณ Tree-Shaking

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';

๐Ÿ”ง TypeScript Support

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 error

๐Ÿš€ Performance

Prodash is optimized for modern JavaScript environments:

  • Uses native Set for deduplication (faster than nested loops)
  • Leverages modern JavaScript APIs when they outperform alternatives
  • Benchmarked against Lodash - equal or better performance
  • Minimal bundle size impact

๐Ÿงช Development

# 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 format

๐ŸŽฎ Playground

Test 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 test

๐Ÿ“„ License

MIT ยฉ Your Name

๐Ÿค Contributing

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

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •