Tea Extend

0.2.0 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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'

view raw JSON →