Registry / serialization / tea-extend

tea-extend

JSON →
library0.2.0jsnpmunverified

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.

npm install tea-extend
INSTALL
IMPORT
SIG · TEA-EXTEND
T
tea-extend
serializationjavascriptv0.2.0
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.

extend
const extend = require('tea-extend');
import extend from 'tea-extend';
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.
extend function (ESM interop)
import * as teaExtend from 'tea-extend'; const extend = teaExtend.default;
import { extend } from 'tea-extend';
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.

Demonstrates how to use `tea-extend` for shallow merging and cloning objects, highlighting its shallow copy behavior.

const extend = require('tea-extend'); // Sample objects const a = { hello: 'world', data: { id: 1 } }; const b = { speak: 'loudly', data: { value: 'test' } }; const c = { foo: 'bar' }; // Extend 'a' with properties from 'b' extend(a, b); console.log('Object a after extend(a, b):', a); // Expected: { hello: 'world', data: { value: 'test' }, speak: 'loudly' } // Shallow clone to 'c' from 'a' const clonedC = extend({}, a, c); console.log('Cloned object c:', clonedC); // Expected: { hello: 'world', data: { value: 'test' }, speak: 'loudly', foo: 'bar' } // Demonstrate shallow copy behavior: modifying nested 'data' in 'a' affects 'b' if not deeply copied a.data.value = 'modified'; console.log('Object b after modifying a.data:', b); // b.data.value will be 'modified'
Debug
Known issues
gotchatea-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.
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.
affects: >=0.1.0
breakingThis 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.
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.
affects: >=0.1.0
deprecatedThe 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.
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.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: (0 , tea_extend_1.default) is not a function
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.
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.
ReferenceError: require is not defined
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`.
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.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
tea-extend — npm install tea-extend · libregistry