Lodash Internal createAssigner Module
lodash._createassigner is a low-level, internal utility module originating from the Lodash v3 ecosystem. Its primary function is to provide the core logic for object assignment operations, which are then used by public Lodash functions like `_.assign` and `_.assignIn`. This module is considered an internal implementation detail and is not intended for direct public consumption; its API is subject to change without notice and it may not be compatible with newer Lodash versions. The current stable version for this specific package is 3.1.1, corresponding to the Lodash v3 major release cycle. Modern Lodash (v4.x and newer) typically advocates for importing specific functions directly from the main `lodash` or `lodash-es` packages for improved tree-shaking and module resolution, rendering these older, granular internal modules largely obsolete. This package does not maintain an independent release cadence but is tied to the Lodash monorepo's overarching development.
Common errors
-
TypeError: createAssigner is not a function
cause Attempting to call `createAssigner` directly as an assignment function, or importing it incorrectly in an ESM-only context.fixEnsure you are using `require('lodash._createassigner')` in a CommonJS environment. Remember that `createAssigner` is a higher-order function that *returns* an assigner function, it doesn't perform assignment itself directly. -
Error: Cannot find module 'lodash._createassigner'
cause The package might not be explicitly installed, or the module resolver cannot find it.fixRun `npm install lodash._createassigner` to ensure the package is available. Also verify that your module resolution paths are correctly configured, especially in non-standard environments. -
ReferenceError: SomeInternalLodashHelper is not defined
cause This internal module might rely on other Lodash internal helpers that are not globally available or correctly resolved when `lodash._createassigner` is used in isolation outside the full Lodash build context.fixThis error strongly indicates misuse of an internal Lodash component. The recommended fix is to stop using `lodash._createassigner` and instead use the official, stable `_.assign` or `_.assignIn` functions from the main `lodash` package.
Warnings
- breaking This package is frozen at version 3.1.1 and corresponds to the Lodash v3 major release. It is not compatible with the internal structures or assumptions of Lodash v4.0.0 and subsequent versions, which introduced significant breaking changes. Relying on this package with a Lodash v4+ installation is likely to cause runtime errors or unexpected behavior.
- gotcha This module is an internal implementation detail of Lodash, not part of its public API. Direct usage is strongly discouraged as its behavior, API signature, or even its existence can change without notice across Lodash major, minor, or even patch versions. Such usage can lead to fragile code that breaks unpredictably.
- breaking As an older, internal module from the Lodash v3 era, `lodash._createassigner` does not receive direct security patches. Modern Lodash (v4.18.0+) has addressed critical prototype pollution vulnerabilities (GHSA-f23m-r3pf-42rh) in functions like `_.unset` and `_.omit` which, while not directly related to `createAssigner`, highlight the risks of using outdated internal modules from a security perspective.
- gotcha This package is exported as a CommonJS module (`require`). It is not designed for direct import using ES module syntax (`import`) in modern JavaScript environments without a build step (like webpack or Rollup) that can transpile CommonJS modules. Attempting direct ESM import will result in runtime errors.
Install
-
npm install lodash._createassigner -
yarn add lodash._createassigner -
pnpm add lodash._createassigner
Imports
- createAssigner
import { createAssigner } from 'lodash._createassigner';const createAssigner = require('lodash._createassigner');
Quickstart
const createAssigner = require('lodash._createassigner');
// lodash._createassigner exports a higher-order function that generates
// specialized assignment functions. This example demonstrates how it
// might be used internally by Lodash to create a simple assignment utility.
// In modern Lodash (v4+), you would typically use `_.assign` or `_.assignIn` directly.
// This is a simplified 'base' function that handles the core property copying logic.
// The `createAssigner` function takes this as an argument.
const baseAssign = function(object, source) {
if (object == null || source == null) return object;
for (const key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
object[key] = source[key];
}
}
return object;
};
// Use createAssigner to get an actual assignment function.
// The parameters to createAssigner (e.g., handling defaults, customizers)
// are complex and reflect internal Lodash logic.
// For a basic 'assign' equivalent, we pass our base function.
const assignFunction = createAssigner(baseAssign);
const target = { a: 1 };
const source1 = { b: 2 };
const source2 = { c: 3 };
// The generated function behaves like Lodash's _.assign, taking multiple source objects.
const result = assignFunction(target, source1, source2);
console.log('Initial target:', { a: 1 });
console.log('Source 1:', source1);
console.log('Source 2:', source2);
console.log('Result of internal assignment:', result); // Expected: { a: 1, b: 2, c: 3 }
// For comparison, modern public API usage would be:
// import { assign } from 'lodash';
// const modernResult = assign({ a: 1 }, { b: 2 }, { c: 3 });
// console.log('Modern Lodash assign result:', modernResult);