Skip to content

radash Introduction

radash is a modern JavaScript utility library initiated by former Google engineer Ethan Dean in 2023, designed specifically for TypeScript projects, providing a zero-dependency, type-safe, high-performance collection of utility functions.

Core Features

🚀 Zero Dependencies

radash is completely dependency-free, with no external packages introduced, ensuring minimal bundle size and fastest loading speed.

typescript
// No need to worry about dependency conflicts
import { map, filter, reduce } from 'radash'

🔒 Type Safety

Designed specifically for TypeScript, providing complete type definitions and type inference, making development safer and more reliable.

typescript
import { isArray, isObject, isString } from 'radash'

// Complete type inference
const result = isArray([1, 2, 3]) // TypeScript knows result is boolean
const obj = { name: 'Alice', age: 25 }
const keys = Object.keys(obj) // Type-safe key retrieval

⚡ High Performance

Optimized algorithm implementations, providing better performance than native methods.

typescript
import { map, filter, reduce } from 'radash'

// High-performance array operations
const numbers = [1, 2, 3, 4, 5]
const doubled = map(numbers, n => n * 2)
const evens = filter(numbers, n => n % 2 === 0)
const sum = reduce(numbers, (acc, n) => acc + n, 0)

🛠️ Modern API

Adopts modern JavaScript features, providing clean and intuitive API design.

typescript
import { debounce, throttle, memo } from 'radash'

// Modern function utilities
const debouncedSearch = debounce(searchFunction, 300)
const throttledScroll = throttle(scrollHandler, 100)
const memoizedCalc = memo(expensiveCalculation)

📦 Modular Design

Supports on-demand imports, only bundling the functions you need, further reducing bundle size.

typescript
// Only import needed functions
import { map } from 'radash/array'
import { debounce } from 'radash/curry'
import { isString } from 'radash/typed'

Comparison with Lodash

Feature Comparison

FeatureRadashLodash
Bundle SizeZero dependencies, smaller sizeHas dependencies, larger size
TypeScript SupportNative support, type-safeRequires additional type packages
ModernizationUses modern JS featuresCompatible with older browsers
PerformanceOptimized modern implementationCompatibility prioritized
Maintenance StatusActively maintainedRelatively lagging maintenance
API DesignClean and intuitiveFeature-rich but complex

Code Comparison

Array Operations

typescript
// Radash - Clean and intuitive
import { map, filter, reduce } from 'radash'

const users = [
  { name: 'Alice', age: 25 },
  { name: 'Bob', age: 30 },
  { name: 'Charlie', age: 35 }
]

const names = map(users, user => user.name)
const adults = filter(users, user => user.age >= 30)
const totalAge = reduce(users, (sum, user) => sum + user.age, 0)

// Lodash - Feature-rich but complex
import _ from 'lodash'

const names = _.map(users, 'name')
const adults = _.filter(users, { age: { $gte: 30 } })
const totalAge = _.sumBy(users, 'age')

Type Checking

typescript
// Radash - Type-safe
import { isArray, isObject, isString } from 'radash'

if (isArray(data)) {
  // TypeScript knows data is an array
  data.forEach(item => console.log(item))
}

// Lodash - Requires additional type packages
import _ from 'lodash'
import type { isArray } from 'lodash'

if (_.isArray(data)) {
  // Requires additional type handling
  (data as any[]).forEach(item => console.log(item))
}

Function Utilities

typescript
// Radash - Modern design
import { debounce, throttle, memo } from 'radash'

const debouncedSearch = debounce(searchFunction, 300)
const throttledScroll = throttle(scrollHandler, 100)
const memoizedCalc = memo(expensiveCalculation)

// Lodash - Traditional design
import _ from 'lodash'

const debouncedSearch = _.debounce(searchFunction, 300)
const throttledScroll = _.throttle(scrollHandler, 100)
const memoizedCalc = _.memoize(expensiveCalculation)

Performance Comparison

typescript
// Radash - Optimized modern implementation
import { map, filter } from 'radash'

const largeArray = Array.from({ length: 100000 }, (_, i) => i)

// Faster execution speed
const doubled = map(largeArray, n => n * 2)
const evens = filter(largeArray, n => n % 2 === 0)

// Lodash - Compatibility prioritized
import _ from 'lodash'

const doubled = _.map(largeArray, n => n * 2)
const evens = _.filter(largeArray, n => n % 2 === 0)

Use Cases

  • TypeScript Projects - Native type support
  • Modern Browser Applications - Leverages modern JS features
  • Performance-sensitive Projects - Optimized algorithm implementations
  • Small Bundle Size Requirements - Zero-dependency design
  • New Project Development - Modern API design

⚠️ Scenarios to Consider Lodash

  • Need to Support Older Browsers - Lodash provides better compatibility
  • Need Complex Chaining Operations - Lodash's chaining API is more mature
  • Need Specific Lodash Features - Some special features may only be available in Lodash

Quick Start

Installation

bash
npm install radash
# or
yarn add radash
# or
pnpm add radash

Basic Usage

typescript
import { map, filter, isArray, debounce } from 'radash'

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

// Type checking
if (isArray(data)) {
  console.log('This is an array')
}

// Function utilities
const debouncedSearch = debounce(searchFunction, 300)

On-demand Imports

typescript
// Only import needed functions
import { map } from 'radash/array'
import { debounce } from 'radash/curry'
import { isString } from 'radash/typed'

Lodash and Radash Bundle Size Comparison

A direct comparison shows that Radash is only about one-fifth the size of Lodash. If Radash can meet your project needs, why stick with Lodash? Radash is a brand new JS utility library, and its size is just a fraction of Lodash.

Lodash Size

Lodash compressed bundle size: 69.8kb, minified + gzipped: 24.4kb, download time: 3G network: 488ms, 4G network: 28ms
lodash size

Radash Size

Radash compressed bundle size: 14.8kb, minified + gzipped: 4.8kb, download time: 3G network: 97ms, 4G network: 6ms
rodash size

Ecosystem

Radash provides rich functional categories:

  • Array - Array operation utilities
  • Async - Asynchronous processing utilities
  • Curry - Functional programming utilities
  • Number - Number processing utilities
  • Object - Object operation utilities
  • Random - Random number generation utilities
  • String - String processing utilities
  • Typed - Type checking utilities

Community Support

Summary

Radash is a utility library designed specifically for modern JavaScript/TypeScript projects, providing a zero-dependency, type-safe, high-performance collection of utility functions. Compared to Lodash, Radash has obvious advantages in type support, bundle size, modernization, and other aspects, making it particularly suitable for new project development.

Choose Radash and enjoy a modern development experience!

Released under the MIT License.