{"id":15464,"library":"lodash._pickbyarray","title":"lodash._pickbyarray - Internal Pick By Array Function (v3)","description":"This package exports `pickByArray`, an internal utility function from the Lodash version 3.x series, specifically `3.0.2`. It was part of a modular build strategy that offered individual Lodash functions as standalone CommonJS modules. This specific function (`_pickByArray`) was an internal helper primarily used by other Lodash methods like `_.pick` and `_.omit` when an array of property names was provided, often with an optional predicate applied to those selected keys. It is distinct from the public `_.pickBy` function, which filters an object's properties based on a predicate applied to all its own enumerable properties. The package has not been updated since the Lodash v3 era (published around January 2015). Modern Lodash (v4.x and above, with current stable version 4.18.1) integrates such functions directly into its core, and its modular `lodash-es` build offers full tree-shaking support, negating the need for these granular, unmaintained internal modules. Developers are strongly advised to use the actively maintained `lodash` or `lodash-es` package and its public APIs.","status":"abandoned","version":"3.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/lodash/lodash","tags":["javascript"],"install":[{"cmd":"npm install lodash._pickbyarray","lang":"bash","label":"npm"},{"cmd":"yarn add lodash._pickbyarray","lang":"bash","label":"yarn"},{"cmd":"pnpm add lodash._pickbyarray","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and exports the function directly. Using 'import' will result in a 'SyntaxError' or 'TypeError' in most modern environments unless transpiled or configured for CJS interop. It has not been updated since Lodash v3.","wrong":"import pickByArray from 'lodash._pickbyarray';","symbol":"pickByArray","correct":"const pickByArray = require('lodash._pickbyarray');"},{"note":"This is the modern, publicly exposed equivalent for filtering object properties based on a predicate, available from the actively maintained 'lodash' or 'lodash-es' library. It is not available or related to the `pickByArray` function in this legacy package.","wrong":"const pickBy = require('lodash._pickbyarray');","symbol":"pickBy","correct":"import { pickBy } from 'lodash-es';"},{"note":"For general Lodash utilities and accessing `_.pickBy` (the public equivalent), import the main 'lodash' or 'lodash-es' package. This package only exports `pickByArray`, not the full Lodash object.","wrong":"import _ from 'lodash._pickbyarray';","symbol":"_","correct":"import _ from 'lodash'; // for ESM\nconst _ = require('lodash'); // for CommonJS"}],"quickstart":{"code":"// This example demonstrates the usage of the legacy lodash._pickbyarray module (v3.x).\n// This internal utility was designed for specific use cases within the Lodash core\n// when an array of keys needed to be processed and optionally filtered.\n// For general object filtering based on a predicate, use the public _.pickBy from the main 'lodash' package (v4.x+).\n\nconst pickByArray = require('lodash._pickbyarray');\n\nconst sourceObject = {\n  id: 1,\n  name: 'Widget',\n  price: 9.99,\n  category: 'Electronics',\n  stock: 150\n};\n\n// Simulate an array of keys that might be selected by another internal Lodash process.\nconst keysToConsider = ['name', 'price', 'stock', 'nonExistentKey'];\n\n// Use pickByArray: it typically takes the object, an array of keys to process,\n// and an optional iteratee/predicate applied to values of those specific keys.\nconst pickedSubset = pickByArray(sourceObject, keysToConsider, (value, key) => {\n  // This predicate filters *among the provided keys*.\n  // Only pick keys where the value is a number and greater than 10.\n  return typeof value === 'number' && value > 10;\n});\n\nconsole.log('Original object:', sourceObject);\nconsole.log('Keys considered by internal logic:', keysToConsider);\nconsole.log('Result using legacy lodash._pickbyarray (filtered subset):', pickedSubset);\n// Expected output: { stock: 150 } (as 9.99 is not > 10)\n\n// For comparison, using the modern, public `_.pickBy` from the main Lodash library:\nconst _ = require('lodash'); // Using require for consistency with the example, but import { pickBy } from 'lodash-es' is preferred for ESM\nconst publicPickByResult = _.pickBy(sourceObject, (value) => {\n  // `_.pickBy` filters the entire object based on the predicate.\n  return typeof value === 'number' && value > 10;\n});\nconsole.log('Result using modern _.pickBy (entire object filtered):', publicPickByResult);\n// Expected output: { stock: 150 }\n","lang":"javascript","description":"Shows how to use the legacy CommonJS `lodash._pickbyarray` module and contrasts its internal usage with the modern, public `_.pickBy` from the main Lodash package."},"warnings":[{"fix":"Migrate to using the actively maintained full `lodash` or `lodash-es` package (current stable v4.18.1). Access the public `_.pickBy` utility (for filtering by predicate) or `_.pick` (for picking specific keys) directly. This ensures you benefit from active maintenance, security patches, and modern ES module support.","message":"This package is abandoned and has not received updates since the Lodash v3 era (published around 2015). Using it in modern applications may lead to compatibility issues with newer JavaScript features, lack of new features, and potential security vulnerabilities present in older Lodash versions that have since been patched in v4.x.","severity":"breaking","affected_versions":">=3.0.2"},{"fix":"For filtering object properties based on a predicate, use `_.pickBy(object, predicate)` from the main `lodash` package. For picking specific keys without a predicate, use `_.pick(object, ['key1', 'key2'])`. Do not attempt to replicate `_.pickBy` functionality using this internal module.","message":"This package exports `pickByArray`, an *internal* Lodash utility function with a specific signature (object, array of keys, optional predicate). It is distinct from the public `_.pickBy` function, which filters an object's properties based on a predicate applied to all properties. `pickByArray` is not intended for general application-level use as a direct replacement for `_.pickBy`.","severity":"gotcha","affected_versions":">=3.0.2"},{"fix":"Refactor imports to use either `import { pickBy } from 'lodash-es';` for ESM environments with tree-shaking, or `const pickBy = require('lodash/pickBy');` for CJS environments, or the full `_` object (`const _ = require('lodash');`).","message":"The strategy of modularizing internal Lodash functions into individual npm packages (e.g., `lodash._pickbyarray`) was primarily part of Lodash's v3 distribution. In Lodash v4 and later, these granular internal modules are no longer maintained or recommended. Modern JavaScript bundlers, when combined with `lodash-es` (the ES module build of Lodash), provide efficient tree-shaking capabilities, making the full `lodash-es` package the preferred and equally performant option for modular usage.","severity":"deprecated","affected_versions":">=3.0.2"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure the package is correctly installed (`npm install lodash._pickbyarray`) and imported using CommonJS `require`: `const pickByArray = require('lodash._pickbyarray');`. For modern usage, consider switching to `_.pickBy` from the main `lodash` package.","cause":"Attempting to use `pickByArray` after an incorrect import, or if the package was not installed/resolved properly. This can also occur if `import pickByArray from 'lodash._pickbyarray';` is used in a CJS context.","error":"TypeError: pickByArray is not a function"},{"fix":"Change your import statement to `const pickByArray = require('lodash._pickbyarray');` for CommonJS compatibility. For modern ES module usage, you should instead use `import { pickBy } from 'lodash-es';` from the actively maintained Lodash ES module build.","cause":"You are attempting to use ES module `import` syntax (`import pickByArray from '...'`) with this CommonJS-only package in a script or environment that does not support ES modules or is not configured to transpile them.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"If you must use this legacy package, either use `const pickByArray = require('lodash._pickbyarray');` directly in your TypeScript file, or add a declaration file (`d.ts`) to inform TypeScript about its CJS export (e.g., `declare module 'lodash._pickbyarray' { function pickByArray<T>(object: T, props: string[], predicate?: (value: T[keyof T], key: keyof T, object: T) => boolean): Partial<T>; export = pickByArray; }`). However, the recommended and type-safe solution is to migrate to `import { pickBy } from 'lodash';` or `import { pickBy } from 'lodash-es';` which have official TypeScript definitions.","cause":"In a TypeScript project, the compiler is correctly identifying that this CommonJS module directly exports a function, which is not treated as a 'default export' in the ES module sense by TypeScript.","error":"[TS] Module '\"lodash._pickbyarray\"' has no default export."}],"ecosystem":"npm"}