Registry / serialization / radash

radash

JSON →
library12.1.1jsnpmunverified

Radash is a modern, functional utility library for JavaScript and TypeScript, providing a comprehensive collection of helper functions with zero external dependencies. It's designed to be simple, powerful, and fully typed, offering alternatives to functions found in older libraries like Lodash while focusing on a smaller bundle size and native ESM support. The library is actively maintained, currently on version 12.1.1, with frequent minor and patch releases. Key differentiators include its strong, native TypeScript typing, which aims to improve type safety compared to libraries that often require extra type packages, and a modular design that facilitates tree-shaking for optimized bundle sizes. Radash focuses on functions that augment modern JavaScript features, intentionally omitting those already well-covered by the language itself, leading to a cleaner and more intuitive API.

npm install radash
INSTALL
IMPORT
SIG · RADASH
R
radash
serializationjavascriptv12.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

* as _
import * as _ from 'radash'
This imports all Radash functions under the '_' namespace, suitable for quick access or familiar usage patterns similar to Lodash.
{ max, sum }
import { max, sum } from 'radash'
import { max, sum } from 'radash/dist/esm'
For tree-shaking and explicit named imports, individual functions should be imported directly from the 'radash' package. Explicit subpath imports like 'radash/array' or 'radash/curry' are also supported for more granular control.
CommonJS require
const { get } = require('radash')
const _ = require('radash')
While primarily targeting ESM, Radash supports CommonJS `require()` syntax. For individual functions, destructuring `require('radash')` is the correct approach. Importing the entire namespace with `const _ = require('radash')` is generally discouraged for modern Node.js applications due to tree-shaking limitations, but may technically work.

This quickstart demonstrates core Radash functionalities including array manipulation (`max`, `sum`), object transformation (`objectify`, `pick`), and robust asynchronous error handling (`tryit`).

import * as _ from 'radash' const gods = [{ name: 'Ra', power: 'sun', rank: 100, culture: 'egypt' }, { name: 'Loki', power: 'tricks', rank: 72, culture: 'norse' }, { name: 'Zeus', power: 'lightning', rank: 96, culture: 'greek' }] // Basic array operations console.log('Max rank god:', _.max(gods, g => g.rank)); console.log('Total rank sum:', _.sum(gods, g => g.rank)); // Object manipulation const godObject = _.objectify( gods, g => g.name.toLowerCase(), g => _.pick(g, ['power', 'rank', 'culture']) ); console.log('Gods as object:', godObject); // Asynchronous operations with error handling const mockApi = { gods: { findByName: async (name) => { if (name === 'loki') throw new Error('Loki is elusive'); return gods.find(g => g.name.toLowerCase() === name); } } }; async function fetchAndLogGod(name) { const [err, god] = await _.try(mockApi.gods.findByName)(name); if (err) { console.error(`Failed to fetch ${name}:`, err.message); } else { console.log(`Fetched ${name}:`, god); } } fetchAndLogGod('ra'); fetchAndLogGod('loki');
Debug
Known issues
breakingThe `sum` function received a 'type safer implementation' in v12.0.0. While intended to improve type inference and correctness, this change could lead to TypeScript errors if previous usage was less strictly typed or relied on implicit coercions.
fix
Review calls to `_.sum` (or `sum` if individually imported) and ensure that the values being summed are explicitly numbers or safely convertible. Adjust types or provide explicit type assertions if necessary.
affects: >=12.0.0
gotchaRadash intentionally avoids polymorphic behavior in some functions (e.g., `_.map` expecting only arrays, not objects) unlike older libraries like Lodash. This design choice promotes stronger type safety and deterministic behavior but means a direct drop-in replacement for highly polymorphic Lodash functions might require code adaptation.
fix
Familiarize yourself with Radash's API for specific data structures. Use dedicated object utilities (e.g., `mapValues`, `mapKeys`) or array utilities (`map`) as appropriate, rather than relying on a single function to handle multiple input types.
affects: >=1.0.0
gotchaWhen migrating from older utility libraries, be aware that Radash omits many functions that have become obsolete due to modern JavaScript features (e.g., optional chaining, null coalescing, native `Array.prototype` methods). Attempting to use these non-existent functions will result in runtime errors.
fix
Consult the Radash documentation for available functions. Where a native JavaScript solution exists, prefer it. For example, instead of a `_.get` with string paths from Lodash, consider optional chaining or `_.get` with a type-safe accessor function as demonstrated in Radash.
affects: >=1.0.0
deprecatedPrior to v10.6.0, Radash was licensed under BSD 3-Clause. As of v10.6.0, the license changed to MIT. While not a breaking functional change, developers relying on the specific terms of the BSD license should be aware of this update.
fix
No code fix required. Ensure your project's license compatibility policies are updated if you upgrade from versions prior to 10.6.0.
affects: <10.6.0
Errors
Common errors & fixes
TypeError: _.someFunction is not a function
Attempting to use a Radash function that is not part of the `_` namespace or is not a named export when using `import * as _ from 'radash'` or `import { someFunction } from 'radash'` respectively. It could also mean the function name is incorrect or it's a function from a different library (e.g., Lodash) that Radash does not provide.
fix
Verify the function name against the Radash documentation. If using `import * as _ from 'radash'`, ensure the function is accessed via `_.functionName`. If using named imports, ensure `functionName` is directly exported. For CommonJS, `const { functionName } = require('radash')` is typical.
TS2307: Cannot find module 'radash' or its corresponding type declarations.
TypeScript cannot locate the module or its type definitions. This typically occurs due to incorrect installation, misconfigured `tsconfig.json` paths, or using an outdated TypeScript version that doesn't properly resolve modern `package.json` 'exports' maps.
fix
Ensure `radash` is correctly installed (`npm install radash` or `yarn add radash`). Verify your `tsconfig.json` includes appropriate `moduleResolution` (e.g., 'NodeNext' or 'Bundler') and `module` (e.g., 'ESNext') settings for modern package resolution. Ensure TypeScript is up-to-date.
Upgrade
Version history
12.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
radash — npm install radash · libregistry