{"id":14962,"library":"tea-extend","title":"Tea Extend","description":"tea-extend is a minimalist JavaScript utility designed for performing shallow object merges, allowing properties from one or more source objects to be copied onto a destination object. This package was initially released around 2012, with its current and seemingly final version being 0.2.0. It predates the widespread adoption of native language features such as `Object.assign()` (ES2015) and object spread syntax (ES2018), which now provide equivalent and often more robust functionality directly within JavaScript. Consequently, tea-extend has likely seen no significant updates or active development for over a decade. Its primary differentiator at the time of its creation was providing a simple, early solution for object merging in both Node.js and browser environments (via Component.js) before these native alternatives became standard practice.","status":"abandoned","version":"0.2.0","language":"javascript","source_language":"en","source_url":"git@github.com:qualiancy/tea-extend","tags":["javascript"],"install":[{"cmd":"npm install tea-extend","lang":"bash","label":"npm"},{"cmd":"yarn add tea-extend","lang":"bash","label":"yarn"},{"cmd":"pnpm add tea-extend","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is a CommonJS module; direct ESM 'import' syntax for the default export may not work as expected in all environments. The named import `import { extend } from 'tea-extend';` will not work at all as it exports only a default.","wrong":"import extend from 'tea-extend';","symbol":"extend","correct":"const extend = require('tea-extend');"},{"note":"When using this CommonJS package in an ESM context, `import * as pkg from 'pkg'` will import the entire module namespace, where the default export is accessible via `pkg.default`. Direct named imports are not supported.","wrong":"import { extend } from 'tea-extend';","symbol":"extend function (ESM interop)","correct":"import * as teaExtend from 'tea-extend';\nconst extend = teaExtend.default;"}],"quickstart":{"code":"const extend = require('tea-extend');\n\n// Sample objects\nconst a = { hello: 'world', data: { id: 1 } };\nconst b = { speak: 'loudly', data: { value: 'test' } };\nconst c = { foo: 'bar' };\n\n// Extend 'a' with properties from 'b'\nextend(a, b);\nconsole.log('Object a after extend(a, b):', a);\n// Expected: { hello: 'world', data: { value: 'test' }, speak: 'loudly' }\n\n// Shallow clone to 'c' from 'a'\nconst clonedC = extend({}, a, c);\nconsole.log('Cloned object c:', clonedC);\n// Expected: { hello: 'world', data: { value: 'test' }, speak: 'loudly', foo: 'bar' }\n\n// Demonstrate shallow copy behavior: modifying nested 'data' in 'a' affects 'b' if not deeply copied\na.data.value = 'modified';\nconsole.log('Object b after modifying a.data:', b); // b.data.value will be 'modified'\n","lang":"javascript","description":"Demonstrates how to use `tea-extend` for shallow merging and cloning objects, highlighting its shallow copy behavior."},"warnings":[{"fix":"For deep merging or cloning, use a dedicated deep merge library (e.g., `lodash.merge`, `rfdc`) or manually implement recursive cloning logic. For shallow merges, native `Object.assign()` or spread syntax are preferred.","message":"tea-extend performs only shallow merges. Nested objects within source objects are copied by reference, not recursively cloned. This means modifications to nested objects in the destination will directly affect the original source objects if they shared references.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"In ESM projects, use `import * as teaExtend from 'tea-extend'; const extend = teaExtend.default;` to access the default export. However, for modern JavaScript, it is strongly recommended to replace `tea-extend` with native `Object.assign()` or object spread syntax for shallow merges.","message":"This package is a CommonJS module (`module.exports`). Attempting to use direct ESM `import` syntax (e.g., `import extend from 'tea-extend';` or `import { extend } from 'tea-extend';`) in an ECMAScript Module (ESM) context may lead to runtime errors or incorrect behavior due to how Node.js handles CJS interop with ESM.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Migrate your codebase to use `Object.assign()` or the object spread syntax for shallow object merging. This eliminates an external dependency and uses standard, actively maintained language features.","message":"The functionality provided by `tea-extend` is now natively available and more robustly implemented through `Object.assign()` (ES2015) and the object spread syntax `{ ...obj1, ...obj2 }` (ES2018). Relying on this older, unmaintained utility is generally discouraged for modern JavaScript development.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"For CommonJS-only modules in an ESM project, access the default export via `import * as teaExtend from 'tea-extend'; const extend = teaExtend.default;`. Alternatively, ensure your file is a CommonJS module, or preferably, replace `tea-extend` with native `Object.assign()` or spread syntax.","cause":"This error typically occurs when attempting to use `import extend from 'tea-extend';` or `import { extend } from 'tea-extend';` in an ESM module context for a package that only provides a CommonJS default export.","error":"TypeError: (0 , tea_extend_1.default) is not a function"},{"fix":"Either convert your file to use ESM `import` syntax (see previous problem entry for how to import CJS modules in ESM) or ensure the file is treated as a CommonJS module. Given the package's age, the best fix is to replace `tea-extend` entirely with `Object.assign()` or object spread syntax.","cause":"This error indicates that you are attempting to use the CommonJS `require()` function in a file that is being interpreted as an ECMAScript Module (ESM), for example, a `.mjs` file or a file in a project with `\"type\": \"module\"` in `package.json`.","error":"ReferenceError: require is not defined"}],"ecosystem":"npm"}