{"id":11622,"library":"radash","title":"Radash Utility Library","description":"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.","status":"active","version":"12.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/rayepps/radash","tags":["javascript","typescript"],"install":[{"cmd":"npm install radash","lang":"bash","label":"npm"},{"cmd":"yarn add radash","lang":"bash","label":"yarn"},{"cmd":"pnpm add radash","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This imports all Radash functions under the '_' namespace, suitable for quick access or familiar usage patterns similar to Lodash.","symbol":"* as _","correct":"import * as _ from 'radash'"},{"note":"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.","wrong":"import { max, sum } from 'radash/dist/esm'","symbol":"{ max, sum }","correct":"import { max, sum } from 'radash'"},{"note":"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.","wrong":"const _ = require('radash')","symbol":"CommonJS require","correct":"const { get } = require('radash')"}],"quickstart":{"code":"import * as _ from 'radash'\n\nconst gods = [{\n  name: 'Ra',\n  power: 'sun',\n  rank: 100,\n  culture: 'egypt'\n}, {\n  name: 'Loki',\n  power: 'tricks',\n  rank: 72,\n  culture: 'norse'\n}, {\n  name: 'Zeus',\n  power: 'lightning',\n  rank: 96,\n  culture: 'greek'\n}]\n\n// Basic array operations\nconsole.log('Max rank god:', _.max(gods, g => g.rank));\nconsole.log('Total rank sum:', _.sum(gods, g => g.rank));\n\n// Object manipulation\nconst godObject = _.objectify(\n  gods, \n  g => g.name.toLowerCase(), \n  g => _.pick(g, ['power', 'rank', 'culture'])\n);\nconsole.log('Gods as object:', godObject);\n\n// Asynchronous operations with error handling\nconst mockApi = {\n  gods: {\n    findByName: async (name) => {\n      if (name === 'loki') throw new Error('Loki is elusive');\n      return gods.find(g => g.name.toLowerCase() === name);\n    }\n  }\n};\n\nasync function fetchAndLogGod(name) {\n  const [err, god] = await _.try(mockApi.gods.findByName)(name);\n  if (err) {\n    console.error(`Failed to fetch ${name}:`, err.message);\n  } else {\n    console.log(`Fetched ${name}:`, god);\n  }\n}\n\nfetchAndLogGod('ra');\nfetchAndLogGod('loki');","lang":"typescript","description":"This quickstart demonstrates core Radash functionalities including array manipulation (`max`, `sum`), object transformation (`objectify`, `pick`), and robust asynchronous error handling (`tryit`)."},"warnings":[{"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.","message":"The `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.","severity":"breaking","affected_versions":">=12.0.0"},{"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.","message":"Radash 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"No code fix required. Ensure your project's license compatibility policies are updated if you upgrade from versions prior to 10.6.0.","message":"Prior 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.","severity":"deprecated","affected_versions":"<10.6.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"TypeError: _.someFunction is not a function"},{"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.","cause":"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.","error":"TS2307: Cannot find module 'radash' or its corresponding type declarations."}],"ecosystem":"npm"}