Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/object/index.ts>patch

A JavaScript extension package for building strong and modern applications.
Latest
function patch
import { patch } from "https://deno.land/x/ayonli_jsext@v0.9.72/object/index.ts";

Copies the key-value pairs that are presented in the source objects but are missing in the target object into the target, later pairs are skipped if the same key already exists.

This function mutates the target object and returns it.

Examples

Example 1

import { patch } from "@ayonli/jsext/object";

const obj1 = { foo: "Hello" };
const obj2 = { foo: "Hi", bar: "World" };

console.log(patch(obj1, obj2)); // { foo: "Hello", bar: "World" }

Type Parameters

T extends { }
U

Parameters

target: T
source: U

Type Parameters

T extends { }
U
V

Parameters

target: T
source1: U
source2: V

Type Parameters

T extends { }
U
V
W

Parameters

target: T
source1: U
source2: V
source3: W

Returns

& T
& U
& V
& W

Parameters

target: object
...sources: any[]