TS-Scribe - v1.2.0
    Preparing search index...

    Function objectDeepMerge

    • Deeply merge two or more objects into a new object.

      Merging is left-to-right: each subsequent object's properties take precedence over the previous ones. For plain objects, properties are recursively merged. Primitives, arrays (by default), and special built-in types (Date, RegExp, Map, Set, etc.) are overwritten by the right-hand value.

      Use objectDeepMerge.withOptions when you need non-default merging behaviour (e.g. array concatenation or a custom depth limit).

      Immutability: Inputs are never modified. Every call returns a fresh object graph.

      Circular references: Detected and handled safely via internal WeakMap tracking — no infinite loops.

      Type Parameters

      • T1
      • T2

      Parameters

      Returns DeepMerge<T1, T2>

      A new deeply-merged object.

      // Basic merge
      const a = { name: 'Alice', meta: { visits: 1 } };
      const b = { meta: { lastSeen: new Date() }, age: 30 };
      const merged = objectDeepMerge(a, b);
      // { name: 'Alice', meta: { visits: 1, lastSeen: ... }, age: 30 }
      // Multiple objects
      const merged = objectDeepMerge({ a: 1 }, { b: 2 }, { c: 3 });
      // { a: 1, b: 2, c: 3 }
      // Custom options via withOptions
      const merged = objectDeepMerge.withOptions({ arrayMerge: 'concat' })(
      { tags: ['js'] },
      { tags: ['css'] }
      );
      // { tags: ['js', 'css'] }
      • Array default: arrays are replaced, not concatenated. Use objectDeepMerge.withOptions with { arrayMerge: 'concat' } to concatenate instead.
      • Special types (Date, RegExp, Map, Set, Error, ArrayBuffer, SharedArrayBuffer, typed arrays, etc.) are treated as atomic — the right-hand value overwrites the left.
      • null is treated as a primitive, not an object. A null on the right will overwrite any left-hand value.
      • Depth limit: defaults to 50 to prevent stack overflow on pathological input. Adjust via objectDeepMerge.withOptions({ maxDepth: … }).
      • Symbol keys are not merged (only enumerable string keys).
    • Deeply merge two or more objects into a new object.

      Merging is left-to-right: each subsequent object's properties take precedence over the previous ones. For plain objects, properties are recursively merged. Primitives, arrays (by default), and special built-in types (Date, RegExp, Map, Set, etc.) are overwritten by the right-hand value.

      Use objectDeepMerge.withOptions when you need non-default merging behaviour (e.g. array concatenation or a custom depth limit).

      Immutability: Inputs are never modified. Every call returns a fresh object graph.

      Circular references: Detected and handled safely via internal WeakMap tracking — no infinite loops.

      Type Parameters

      • T1
      • T2
      • T3

      Parameters

      Returns DeepMerge<DeepMerge<T1, T2>, T3>

      A new deeply-merged object.

      // Basic merge
      const a = { name: 'Alice', meta: { visits: 1 } };
      const b = { meta: { lastSeen: new Date() }, age: 30 };
      const merged = objectDeepMerge(a, b);
      // { name: 'Alice', meta: { visits: 1, lastSeen: ... }, age: 30 }
      // Multiple objects
      const merged = objectDeepMerge({ a: 1 }, { b: 2 }, { c: 3 });
      // { a: 1, b: 2, c: 3 }
      // Custom options via withOptions
      const merged = objectDeepMerge.withOptions({ arrayMerge: 'concat' })(
      { tags: ['js'] },
      { tags: ['css'] }
      );
      // { tags: ['js', 'css'] }
      • Array default: arrays are replaced, not concatenated. Use objectDeepMerge.withOptions with { arrayMerge: 'concat' } to concatenate instead.
      • Special types (Date, RegExp, Map, Set, Error, ArrayBuffer, SharedArrayBuffer, typed arrays, etc.) are treated as atomic — the right-hand value overwrites the left.
      • null is treated as a primitive, not an object. A null on the right will overwrite any left-hand value.
      • Depth limit: defaults to 50 to prevent stack overflow on pathological input. Adjust via objectDeepMerge.withOptions({ maxDepth: … }).
      • Symbol keys are not merged (only enumerable string keys).
    • Deeply merge two or more objects into a new object.

      Merging is left-to-right: each subsequent object's properties take precedence over the previous ones. For plain objects, properties are recursively merged. Primitives, arrays (by default), and special built-in types (Date, RegExp, Map, Set, etc.) are overwritten by the right-hand value.

      Use objectDeepMerge.withOptions when you need non-default merging behaviour (e.g. array concatenation or a custom depth limit).

      Immutability: Inputs are never modified. Every call returns a fresh object graph.

      Circular references: Detected and handled safely via internal WeakMap tracking — no infinite loops.

      Type Parameters

      • T1
      • T2
      • T3
      • T4

      Parameters

      Returns DeepMerge<DeepMerge<DeepMerge<T1, T2>, T3>, T4>

      A new deeply-merged object.

      // Basic merge
      const a = { name: 'Alice', meta: { visits: 1 } };
      const b = { meta: { lastSeen: new Date() }, age: 30 };
      const merged = objectDeepMerge(a, b);
      // { name: 'Alice', meta: { visits: 1, lastSeen: ... }, age: 30 }
      // Multiple objects
      const merged = objectDeepMerge({ a: 1 }, { b: 2 }, { c: 3 });
      // { a: 1, b: 2, c: 3 }
      // Custom options via withOptions
      const merged = objectDeepMerge.withOptions({ arrayMerge: 'concat' })(
      { tags: ['js'] },
      { tags: ['css'] }
      );
      // { tags: ['js', 'css'] }
      • Array default: arrays are replaced, not concatenated. Use objectDeepMerge.withOptions with { arrayMerge: 'concat' } to concatenate instead.
      • Special types (Date, RegExp, Map, Set, Error, ArrayBuffer, SharedArrayBuffer, typed arrays, etc.) are treated as atomic — the right-hand value overwrites the left.
      • null is treated as a primitive, not an object. A null on the right will overwrite any left-hand value.
      • Depth limit: defaults to 50 to prevent stack overflow on pathological input. Adjust via objectDeepMerge.withOptions({ maxDepth: … }).
      • Symbol keys are not merged (only enumerable string keys).
    • Deeply merge two or more objects into a new object.

      Merging is left-to-right: each subsequent object's properties take precedence over the previous ones. For plain objects, properties are recursively merged. Primitives, arrays (by default), and special built-in types (Date, RegExp, Map, Set, etc.) are overwritten by the right-hand value.

      Use objectDeepMerge.withOptions when you need non-default merging behaviour (e.g. array concatenation or a custom depth limit).

      Immutability: Inputs are never modified. Every call returns a fresh object graph.

      Circular references: Detected and handled safely via internal WeakMap tracking — no infinite loops.

      Type Parameters

      • T1
      • T2
      • T3
      • T4
      • T5

      Parameters

      Returns DeepMerge<DeepMerge<DeepMerge<DeepMerge<T1, T2>, T3>, T4>, T5>

      A new deeply-merged object.

      // Basic merge
      const a = { name: 'Alice', meta: { visits: 1 } };
      const b = { meta: { lastSeen: new Date() }, age: 30 };
      const merged = objectDeepMerge(a, b);
      // { name: 'Alice', meta: { visits: 1, lastSeen: ... }, age: 30 }
      // Multiple objects
      const merged = objectDeepMerge({ a: 1 }, { b: 2 }, { c: 3 });
      // { a: 1, b: 2, c: 3 }
      // Custom options via withOptions
      const merged = objectDeepMerge.withOptions({ arrayMerge: 'concat' })(
      { tags: ['js'] },
      { tags: ['css'] }
      );
      // { tags: ['js', 'css'] }
      • Array default: arrays are replaced, not concatenated. Use objectDeepMerge.withOptions with { arrayMerge: 'concat' } to concatenate instead.
      • Special types (Date, RegExp, Map, Set, Error, ArrayBuffer, SharedArrayBuffer, typed arrays, etc.) are treated as atomic — the right-hand value overwrites the left.
      • null is treated as a primitive, not an object. A null on the right will overwrite any left-hand value.
      • Depth limit: defaults to 50 to prevent stack overflow on pathological input. Adjust via objectDeepMerge.withOptions({ maxDepth: … }).
      • Symbol keys are not merged (only enumerable string keys).
    • Deeply merge two or more objects into a new object.

      Merging is left-to-right: each subsequent object's properties take precedence over the previous ones. For plain objects, properties are recursively merged. Primitives, arrays (by default), and special built-in types (Date, RegExp, Map, Set, etc.) are overwritten by the right-hand value.

      Use objectDeepMerge.withOptions when you need non-default merging behaviour (e.g. array concatenation or a custom depth limit).

      Immutability: Inputs are never modified. Every call returns a fresh object graph.

      Circular references: Detected and handled safely via internal WeakMap tracking — no infinite loops.

      Type Parameters

      • T extends any[]

        The tuple of types to merge.

      Parameters

      • ...objects: T

        Two or more objects to merge.

      Returns DeepMergeTuple<T>

      A new deeply-merged object.

      // Basic merge
      const a = { name: 'Alice', meta: { visits: 1 } };
      const b = { meta: { lastSeen: new Date() }, age: 30 };
      const merged = objectDeepMerge(a, b);
      // { name: 'Alice', meta: { visits: 1, lastSeen: ... }, age: 30 }
      // Multiple objects
      const merged = objectDeepMerge({ a: 1 }, { b: 2 }, { c: 3 });
      // { a: 1, b: 2, c: 3 }
      // Custom options via withOptions
      const merged = objectDeepMerge.withOptions({ arrayMerge: 'concat' })(
      { tags: ['js'] },
      { tags: ['css'] }
      );
      // { tags: ['js', 'css'] }
      • Array default: arrays are replaced, not concatenated. Use objectDeepMerge.withOptions with { arrayMerge: 'concat' } to concatenate instead.
      • Special types (Date, RegExp, Map, Set, Error, ArrayBuffer, SharedArrayBuffer, typed arrays, etc.) are treated as atomic — the right-hand value overwrites the left.
      • null is treated as a primitive, not an object. A null on the right will overwrite any left-hand value.
      • Depth limit: defaults to 50 to prevent stack overflow on pathological input. Adjust via objectDeepMerge.withOptions({ maxDepth: … }).
      • Symbol keys are not merged (only enumerable string keys).