{"library":"lodash._cacheindexof","title":"Lodash Internal `cacheIndexOf` Module","description":"This package exports a specific internal utility function, `cacheIndexOf`, from the Lodash library as a standalone Node.js module. It is part of the modular builds approach popular during the Lodash v3.x era. The function is designed for optimized index lookups within arrays, often used by other internal Lodash methods for tasks like `_.uniq` or `_.intersection` where efficiently checking for previously seen values is crucial. This package is version 3.0.2, reflecting its origin in the Lodash v3 codebase. While the main Lodash library (currently at v4.x) continues active development with a regular release cadence, this specific internal sub-package has remained static since its release, receiving no further updates. Its key differentiator is providing a minimal footprint for this specialized internal logic, but it's not intended for general application development outside of deeply understanding Lodash internals. It should be considered stable but effectively abandoned in terms of active maintenance.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install lodash._cacheindexof"],"cli":null},"imports":["const cacheIndexOf = require('lodash._cacheindexof');","import cacheIndexOf from 'lodash._cacheindexof';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// This package exposes an internal Lodash v3 function, `cacheIndexOf`.\n// It is typically not used directly by application developers but is leveraged by other Lodash modules\n// for performance optimization in operations like `_.uniq` or `_.intersection`.\n// Its purpose is to efficiently find the index of a value within an array, potentially using an auxiliary 'cache' array.\n\n// Installation: npm install lodash._cacheindexof\n\nconst cacheIndexOf = require('lodash._cacheindexof');\n\nfunction demonstrateCacheIndexOf() {\n  const dataArray = ['apple', 'banana', 'orange', 'grape', 'banana'];\n  const searchTerm1 = 'orange';\n  const searchTerm2 = 'grapefruit';\n  const searchTerm3 = 'banana';\n\n  // The 'cache' parameter is an internal array used by Lodash to track seen values\n  // for performance optimization. When used directly, it can act as a simple auxiliary array.\n  // In a full Lodash implementation, this might be a Set or another tracking mechanism.\n  const internalCache = []; \n\n  // Find an existing item\n  let index = cacheIndexOf(dataArray, searchTerm1, internalCache);\n  console.log(`'${searchTerm1}' found at index: ${index}`); // Expected: 2\n\n  // Find a non-existing item\n  index = cacheIndexOf(dataArray, searchTerm2, internalCache);\n  console.log(`'${searchTerm2}' found at index: ${index}`); // Expected: -1\n\n  // Find a duplicate item. Note: cacheIndexOf finds the *first* occurrence.\n  index = cacheIndexOf(dataArray, searchTerm3, internalCache);\n  console.log(`'${searchTerm3}' found at index: ${index}`); // Expected: 1\n\n  // The 'internalCache' array's modification by `cacheIndexOf` is context-dependent\n  // within Lodash's full algorithms. For simple lookups as shown, it might remain unchanged.\n  console.log(`State of internalCache after calls: ${JSON.stringify(internalCache)}`);\n}\n\ndemonstrateCacheIndexOf();\n","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}