Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@recursive/assign

omrilotan18.1kUNLICENSE3.0.1TypeScript support: included

💠 Recursive assign for objects, arrays and more

💠, deep, merge, extend, mixin, recursive, key, keys, object, array, function, set, map, properties, property, props, prop, values, value

readme

@recursive/assign

💠 Recursive assign for objects, arrays and more

import { assign } from "@recursive/assign";

assign({ hash: { a: 1 } }, { hash: { b: 2, c: 0 } }, { hash: { c: 3 } }); // {hash: {a: 1, b:2, c: 3}}

I will merge:

  • ✔ objects
  • ✔ arrays
  • ✔ functions
  • ✔ sets
  • ✔ maps

Array

assign({ array: [1, 2, 3] }, { array: [3, 4] });
// {array: [3, 4, 3]}

Array of assignable members

assign(
    [{ firstName: "Omri" }, { firstName: "Tom" }],
    [{ lastName: "Lotan" }, { lastName: "Ben Amitai" }],
);
// [{firstName: 'Omri', lastName: 'Lotan'}, {firstName: 'Tom', lastName: 'Ben Amitai'}]

Set

assign({ set: new Set([1, 2]) }, { set: new Set([2, 3]) });
// {set: [1, 2, 3]}

Map

assign(
    {map: new Map([[1, 2], [3, 4]])}
    {map: new Map([[1, 3], [4, 5]])}
);
// {map: [[1, 3], [3, 4], [4, 5]]}