Registry / lodash._basecopy

lodash._basecopy

JSON →
library3.0.1jsnpmunverified

lodash._basecopy is an internal Lodash module, specifically version 3.0.1, published over a decade ago in April 2015. It exposes the `baseCopy` function, which is a core utility used internally by Lodash for copying object properties. This package is part of the older Lodash v3 ecosystem, which predates the significant breaking changes and modularization introduced in Lodash v4. While Lodash itself (currently v4.18.1) is actively maintained with a regular release cadence addressing bugs and security, `lodash._basecopy` is effectively abandoned as a standalone, directly consumable package. Modern Lodash encourages direct function imports from `lodash` or `lodash-es` rather than using these older, internal micro-modules, many of which are slated for removal in Lodash v5.

npm install lodash._basecopy
INSTALL
IMPORT
SIG · LODASH._BASECOPY
L
lodash._basecopy
javascriptv3.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

baseCopy
const baseCopy = require('lodash._basecopy');
import baseCopy from 'lodash._basecopy';
This package is a CommonJS module from Lodash v3 era and is not designed for direct ES module imports. Its use is strongly discouraged in modern applications.
baseCopy (modern equivalent)
import { assign } from 'lodash'; // Or for deep cloning: import { cloneDeep } from 'lodash';
In modern Lodash (v4+), internal functions like `baseCopy` are not typically exposed directly. Use public API functions like `_.assign()` for shallow copies or `_.cloneDeep()` for deep copies. For ES Modules, consider `lodash-es` or direct imports like `import assign from 'lodash/assign';` for better tree-shaking.

Demonstrates how to use the `lodash._basecopy` CommonJS module for shallow copying and compares it to modern Lodash public API equivalents for shallow and deep copies.

const baseCopy = require('lodash._basecopy'); const source = { a: 1, b: { c: 2 } }; const destination = {}; // Using baseCopy to copy properties. Note: baseCopy is a low-level internal function // and doesn't handle deep cloning or complex scenarios by itself. // It typically expects a mutatable destination and source object. function customCopy(dest, src) { baseCopy(src, dest); return dest; } const copiedObject = customCopy({}, source); console.log('Source:', source); // { a: 1, b: { c: 2 } } console.log('Copied:', copiedObject); // { a: 1, b: { c: 2 } } console.log('Are they the same object for key `b`?', copiedObject.b === source.b); // true (shallow copy) // Demonstrating direct Lodash v4+ equivalent for shallow copy const _ = require('lodash'); const shallowCopyModern = _.assign({}, source); console.log('Modern Lodash assign (shallow):', shallowCopyModern); console.log('Are they the same object for key `b` (modern)?', shallowCopyModern.b === source.b); // true (shallow copy) // For deep copy, which baseCopy alone wouldn't provide: const deepCopyModern = _.cloneDeep(source); console.log('Modern Lodash cloneDeep (deep):', deepCopyModern); console.log('Are they the same object for key `b` (deep)?', deepCopyModern.b === source.b); // false (deep copy)
Debug
Known issues
breakingThis package is an internal Lodash v3 module. Lodash v4 introduced significant breaking changes, and internal module structures are not guaranteed to be stable or compatible across major versions. Direct usage of `lodash._basecopy` in a Lodash v4+ environment is unsupported and likely to cause issues or unexpected behavior.
fix
Migrate to using public Lodash API functions like `_.assign()`, `_.clone()` or `_.cloneDeep()` directly from the main `lodash` package. For specific functions, import them directly (e.g., `require('lodash/assign')` or `import assign from 'lodash/assign'`).
affects: >=4.0.0
deprecatedDirect use of individual 'per method' packages like `lodash._basecopy` is strongly discouraged by the Lodash team and these packages are slated for removal in Lodash v5. They can lead to larger bundle sizes due to internal bundling of shared dependencies.
fix
Instead of `require('lodash._basecopy')`, use direct function imports from the main `lodash` package (e.g., `require('lodash/assign')` for CJS or `import assign from 'lodash/assign'` for ESM with tree-shaking bundlers like Webpack/Rollup). For more complex scenarios, import the full `lodash` package and use its methods.
affects: >=3.0.1
gotcha`lodash._basecopy` performs a shallow copy. If you require a deep copy for nested objects or arrays, `baseCopy` alone is insufficient and will lead to unexpected mutation of original objects.
fix
For deep copying, use `_.cloneDeep()` from the main Lodash library. Ensure you understand the difference between shallow and deep copies for your use case.
affects: >=3.0.1
gotchaThis specific package (`lodash._basecopy`) has not received updates since 2015. While the main `lodash` package has had security advisories (e.g., prototype pollution fixes in v4.18.0), using outdated internal modules means you are not benefiting from these critical security patches.
fix
Migrate away from this package to supported methods within the actively maintained `lodash` package (version 4.18.1 or newer) to ensure you receive important security updates.
affects: =3.0.1
Errors
Common errors & fixes
TypeError: baseCopy is not a function
Attempting to use `baseCopy` after importing it incorrectly, or if the `lodash._basecopy` package is not correctly installed or resolved in a modern environment. It might also occur if the function's internal dependencies or signature changed in an incompatible Lodash version.
fix
Ensure the package is installed (`npm install lodash._basecopy`) if you must use it (though not recommended). More importantly, migrate to standard Lodash functions like `_.assign` or `_.cloneDeep` which are actively supported and exposed in the main `lodash` package.
Error: Can't walk dependency graph: Cannot find module 'lodash/string/template'
While not directly for `_basecopy`, this error illustrates the problem with older Lodash sub-path imports being removed or moved in Lodash v4. This package `_basecopy` is also a granular module that could similarly become unresolvable.
fix
For `_basecopy` and similar granular modules, switch to the main `lodash` package and import specific functions like `import { assign } from 'lodash';` or `const assign = require('lodash/assign');`. If using a bundler with tree-shaking, `import { assign } from 'lodash';` can be optimized.
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources