{"id":15457,"library":"lodash._baseassign","title":"Lodash Internal `baseAssign` Utility","description":"This package provides the internal `baseAssign` function from Lodash version 3.2.0, exporting it as a CommonJS module. `baseAssign` is a low-level utility responsible for shallowly assigning enumerable own properties from source objects to a destination object, serving as a building block for higher-level Lodash methods like `_.assign`. Published in 2015, this specific package is tied to an end-of-life major version of Lodash (v3.x, supported until January 2016). While Lodash (currently v4.x) remains actively maintained with a continuous release cadence, this individual internal module is not independently updated. Modern best practices for consuming Lodash functions involve importing directly from the main `lodash` package (e.g., `require('lodash/assign')` or `import assign from 'lodash/assign'`) or utilizing `lodash-es` with tree-shaking bundlers to optimize bundle size. Per-method packages like this one are discouraged and are slated for removal in Lodash v5.","status":"abandoned","version":"3.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/lodash/lodash","tags":["javascript"],"install":[{"cmd":"npm install lodash._baseassign","lang":"bash","label":"npm"},{"cmd":"yarn add lodash._baseassign","lang":"bash","label":"yarn"},{"cmd":"pnpm add lodash._baseassign","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and tied to Lodash v3.x. Native ES module imports are not supported. For modern applications, prefer `import assign from 'lodash/assign'` from the main `lodash` package or `lodash-es` for tree-shaking.","wrong":"import { baseAssign } = from 'lodash._baseassign';","symbol":"baseAssign","correct":"const baseAssign = require('lodash._baseassign');"}],"quickstart":{"code":"const baseAssign = require('lodash._baseassign');\n\nconst target = { a: 1 };\nconst source1 = { b: 2 };\nconst source2 = { c: 3, a: 4 }; // 'a' will be overwritten by source1 if applied first\n\n// baseAssign is internal and typically takes a single source\nconst result = baseAssign(target, source1);\nconsole.log('Result after baseAssign(target, source1):', result);\n// Expected: { a: 1, b: 2 }\n\nconst anotherTarget = {};\nconst sourceObj = { propA: 1, propB: { nested: true } };\nconst assignedObj = baseAssign(anotherTarget, sourceObj);\nconsole.log('Assigned object:', assignedObj);\nconsole.log('Is it a shallow copy?', assignedObj.propB === sourceObj.propB); // Should be true\n\n// Demonstrate its internal nature: it's not a public _.assign\n// For multiple sources or customizers, use _.assign from the main lodash package.\nconst _ = require('lodash'); // Using the main lodash package for comparison\nconst finalObject = _.assign({}, {x: 1}, {y: 2}, {x: 3});\nconsole.log('Result using _.assign from main lodash:', finalObject);","lang":"javascript","description":"This code demonstrates how to `require` and use the `baseAssign` function for shallow property assignment. It also highlights that `baseAssign` is an internal, low-level utility, contrasting its usage with the public `_.assign` method from the main Lodash library."},"warnings":[{"fix":"Migrate to Lodash v4.x by installing `lodash` (the main package). Use `require('lodash/assign')` or `import assign from 'lodash/assign'` instead of `lodash._baseassign`. Consult the Lodash v3 to v4 migration guide.","message":"This package is based on Lodash v3.2.0, an End-of-Life (EOL) version. Many APIs, behaviors, and internal structures changed significantly in Lodash v4.x, which was released in 2016. Code written for v3.x is unlikely to be directly compatible with v4.x equivalents without migration.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use specific methods directly from the main `lodash` package (e.g., `require('lodash/assign')` for CommonJS or `import assign from 'lodash/assign'` for ESM with `lodash-es`) or use bundler plugins (like `babel-plugin-lodash`) for optimized builds.","message":"Using granular internal modules like `lodash._baseassign` is strongly discouraged by the Lodash team. These packages are considered legacy, can increase `node_modules` size, and are planned for removal in Lodash v5.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"In CommonJS environments, use `const baseAssign = require('lodash._baseassign');`. For ES module environments, you will need to rely on a CommonJS interop layer or, preferably, use `lodash-es` or `lodash/assign` from the main `lodash` package.","message":"This package is CommonJS-only, meaning it cannot be directly imported using ES module `import` syntax (`import { baseAssign } from 'lodash._baseassign'`). Attempting to do so will result in runtime errors.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Upgrade to the latest stable version of the main `lodash` package (currently v4.x) to ensure you receive critical security updates.","message":"As an EOL version (v3.x), `lodash._baseassign` is no longer supported and will not receive security patches for newly discovered vulnerabilities. While the provided advisories mention v4.x vulnerabilities, similar issues could exist in older codebases.","severity":"breaking","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"For CommonJS, use `const baseAssign = require('lodash._baseassign');`. For ESM, you must use a CommonJS interop layer or, better yet, migrate to `import assign from 'lodash/assign'` from the main `lodash` package.","cause":"Attempting to use `import { baseAssign } from 'lodash._baseassign'` in an ES module environment, or `require` with a non-existent path. This package only exports `baseAssign` as a default CommonJS export.","error":"baseAssign is not a function"},{"fix":"`baseAssign` is a utility function and should be called directly, e.g., `baseAssign({}, source)`.","cause":"Trying to instantiate `baseAssign` with `new`, which is not a constructor function.","error":"TypeError: baseAssign is not a constructor"}],"ecosystem":"npm"}