Lodash Internal Array Map Module (v3)
This package exports `lodash`'s internal `arrayMap` function, specifically from the `lodash` v3 ecosystem, as a standalone CommonJS module. Released around 2015, it was designed for specific modular builds of Lodash rather than general direct consumption. The core `lodash` library, now in its v4 series, has evolved significantly, and developers are strongly advised to use the stable `_.map` function directly from the main `lodash` or `lodash-es` packages. This specific internal module is no longer actively maintained or updated independently, and its usage is generally discouraged in favor of stable, public APIs. The main `lodash` library follows semantic versioning with a generally active release cadence, but this specific module is tied to an older, unmaintained major version.
Common errors
-
ReferenceError: require is not defined
cause Attempting to use `require('lodash._arraymap')` in an ES module context (e.g., a file with `type: module` or `.mjs` extension).fixThis package is CommonJS only. Either convert your file to a CommonJS module, use dynamic `import()` (if supported by your environment), or preferably, switch to `lodash-es` and use its `map` function. -
TypeError: arrayMap is not a function
cause Incorrectly importing the module (e.g., `import arrayMap from 'lodash._arraymap';` in CJS, or a typo in the variable name) or attempting to call it with non-array arguments that it's not designed to handle.fixEnsure the import is `const arrayMap = require('lodash._arraymap');` and that `arrayMap` is called with an array as the first argument and a function as the second, matching its internal signature.
Warnings
- breaking The `lodash._arraymap` package is an internal module from Lodash v3.0.0. Its API and existence are not guaranteed across Lodash major versions. Direct usage may break without warning when migrating to newer Lodash versions (v4+) or when other parts of the ecosystem expect `lodash` v4+ behavior.
- deprecated Users should utilize the stable and public `_.map` function from the main `lodash` or `lodash-es` packages instead of this internal utility. `_.map` provides a documented API that handles various collection types, is actively maintained, and receives security updates.
- gotcha This module is a CommonJS-only package. It does not provide ES module (ESM) exports, which can lead to compatibility issues or require specific configuration when used in modern JavaScript projects that primarily target ESM.
- gotcha While this specific package `lodash._arraymap` v3.0.0 is very old and unmaintained, the main `lodash` library has had critical security advisories (e.g., prototype pollution fixes in v4.18.0). Using old, unmaintained internal modules like this could potentially expose applications to vulnerabilities if they bypass the hardened, public APIs of newer Lodash versions.
Install
-
npm install lodash._arraymap -
yarn add lodash._arraymap -
pnpm add lodash._arraymap
Imports
- arrayMap
const arrayMap = require('lodash._arraymap');
Quickstart
const arrayMap = require('lodash._arraymap');
const numbers = [1, 2, 3];
const doubledNumbers = arrayMap(numbers, (n) => n * 2);
console.log('Original numbers:', numbers);
console.log('Doubled numbers (via _arraymap):', doubledNumbers);
// For comparison, using modern lodash's _.map (recommended):
// const _ = require('lodash'); // Or import { map } from 'lodash';
// const modernDoubled = _.map(numbers, (n) => n * 2);
// console.log('Doubled numbers (via _.map):', modernDoubled);