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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
cacheIndexOf
✓ const cacheIndexOf = require('lodash._cacheindexof');
This package primarily supports CommonJS modules, aligning with its Lodash v3 origin and the Node.js module system predominant at that time.
cacheIndexOf
✓ import cacheIndexOf from 'lodash._cacheindexof';
✗ import { cacheIndexOf } from 'lodash._cacheindexof';
While this package is CommonJS-first, modern bundlers can often resolve it via a default ESM import. Avoid named imports as the module exports a single function as its default.
Demonstrates the direct usage of the internal `cacheIndexOf` function, highlighting its signature with an array, value, and an internal 'cache' array parameter for optimized lookups, as it would be used within Lodash v3.x.
// This package exposes an internal Lodash v3 function, `cacheIndexOf`.
// It is typically not used directly by application developers but is leveraged by other Lodash modules
// for performance optimization in operations like `_.uniq` or `_.intersection`.
// Its purpose is to efficiently find the index of a value within an array, potentially using an auxiliary 'cache' array.
// Installation: npm install lodash._cacheindexof
const cacheIndexOf = require('lodash._cacheindexof');
function demonstrateCacheIndexOf() {
const dataArray = ['apple', 'banana', 'orange', 'grape', 'banana'];
const searchTerm1 = 'orange';
const searchTerm2 = 'grapefruit';
const searchTerm3 = 'banana';
// The 'cache' parameter is an internal array used by Lodash to track seen values
// for performance optimization. When used directly, it can act as a simple auxiliary array.
// In a full Lodash implementation, this might be a Set or another tracking mechanism.
const internalCache = [];
// Find an existing item
let index = cacheIndexOf(dataArray, searchTerm1, internalCache);
console.log(`'${searchTerm1}' found at index: ${index}`); // Expected: 2
// Find a non-existing item
index = cacheIndexOf(dataArray, searchTerm2, internalCache);
console.log(`'${searchTerm2}' found at index: ${index}`); // Expected: -1
// Find a duplicate item. Note: cacheIndexOf finds the *first* occurrence.
index = cacheIndexOf(dataArray, searchTerm3, internalCache);
console.log(`'${searchTerm3}' found at index: ${index}`); // Expected: 1
// The 'internalCache' array's modification by `cacheIndexOf` is context-dependent
// within Lodash's full algorithms. For simple lookups as shown, it might remain unchanged.
console.log(`State of internalCache after calls: ${JSON.stringify(internalCache)}`);
}
demonstrateCacheIndexOf();
Debug
Known issues
breakingThis package is tied to Lodash v3.0.2. Lodash v4.0.0 introduced significant breaking changes to many core functions, including argument order, removed methods (e.g., `_.where`, `_.findWhere`), and behavior modifications. Using `lodash._cacheindexof` (v3.x) alongside a main `lodash` (v4.x) library or expecting v4+ behavior is highly discouraged and will likely lead to errors due to API incompatibility.fixFor new projects or modern environments, avoid this specific internal v3 module. If Lodash utilities are needed, use the main `lodash` package (v4.x) and import methods directly from it (e.g., `require('lodash/indexOf')`) or use tree-shaking bundlers. affects: >=3.0.0
securityLodash v3.x, which this package is based on, has known unpatched high-severity security vulnerabilities, including prototype pollution (CVE-2020-8203) and code injection (CVE-2021-23337) via functions like `_.merge`, `_.defaultsDeep`, and `_.template`. While `cacheIndexOf` itself might not be directly exploitable for these specific CVEs, relying on an unmaintained Lodash v3 component introduces potential supply chain risks and exposes applications to broader vulnerabilities within the v3 ecosystem.fixMigrate to the actively maintained Lodash v4.x, or consider using alternative security-patched versions of Lodash 3.x if available from third-party vendors (e.g., HeroDevs' Never-Ending Support).
affects: >=3.0.0 <=3.10.1
deprecatedThe practice of using standalone per-method or internal Lodash packages (like `lodash._cacheindexof`) is officially discouraged and these packages are slated for removal in Lodash v5. They can increase `node_modules` size and bundle duplication compared to importing methods directly from the main `lodash` package with modern bundlers or `babel-plugin-lodash`.fixInstead of `require('lodash._cacheindexof')`, consider `require('lodash/indexOf')` for general index finding, or integrate with the main `lodash` package and rely on tree-shaking for bundle size optimization. affects: >=3.0.0
gotchaThis module exports an internal Lodash function. Its behavior, particularly how it interacts with the `cache` parameter, is tied to the specific internal implementations of Lodash v3. It is not a general-purpose, publicly documented API and its direct use requires deep familiarity with Lodash's internal workings. Misunderstanding its specialized context can lead to incorrect or inefficient usage.fixFor typical application development, use the stable and documented public API of the main `lodash` package (e.g., `_.indexOf`, `_.findIndex`, `_.lastIndexOf`) instead of internal modules. Refer to the official Lodash documentation for appropriate methods.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: cacheIndexOf is not a function
Attempting to import `cacheIndexOf` using a named import (e.g., `import { cacheIndexOf } from 'lodash._cacheindexof';`) when the module provides a default export.
fixUse a default import for ESM (`import cacheIndexOf from 'lodash._cacheindexof';`) or CommonJS `require` syntax (`const cacheIndexOf = require('lodash._cacheindexof');`). ReferenceError: cacheIndexOf is not defined
The `cacheIndexOf` function was not correctly imported or assigned to a variable in the current scope, often by directly calling it without a `require` or `import` statement, or if the package itself failed to load.
fixEnsure the module is properly imported and assigned: `const cacheIndexOf = require('lodash._cacheindexof');` for CommonJS, or `import cacheIndexOf from 'lodash._cacheindexof';` for ES Modules. Verify the package is installed in `node_modules`. Audit
Dependencies
No dependency data recorded yet.