Skip to content

Latest commit

 

History

History
116 lines (87 loc) · 2.66 KB

deepmerge.md

File metadata and controls

116 lines (87 loc) · 2.66 KB

模板版本:v0.1.3

deepmerge

License

[!tip] Github 地址

安装与使用

进入到工程目录并输入以下命令:

npm

npm install deepmerge@^4.3.1

yarn

yarn add deepmerge@^4.3.1

快速使用:

import deepmerge from "deepmerge";

const x = {
  foo: { bar: 3 },
  array: [
    {
      does: "work",
      too: [1, 2, 3],
    },
  ],
};

const y = {
  foo: { baz: 4 },
  quux: 5,
  array: [
    {
      does: "work",
      too: [4, 5, 6],
    },
    {
      really: "yes",
    },
  ],
};

const output = {
  foo: {
    bar: 3,
    baz: 4,
  },
  array: [
    {
      does: "work",
      too: [1, 2, 3],
    },
    {
      does: "work",
      too: [4, 5, 6],
    },
    {
      really: "yes",
    },
  ],
  quux: 5,
};

deepmerge(x, y); // => output

约束与限制

兼容性

在下述版本验证通过:

  1. RNOH:0.72.11; SDK:OpenHarmony(api11) 4.1.0.53; IDE:DevEco Studio 4.1.3.412; ROM:2.0.0.52;
  2. RNOH:0.72.13; SDK:HarmonyOS NEXT Developer Preview1; IDE:DevEco Studio 4.1.3.500; ROM:2.0.0.58;

API

[!tip] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。

详情见 deepmerge源库地址

Name Description Type Required HarmonyOS Support
deepmerge(x, y, [options]) Merge two objects x and y deeply, returning a new merged object with the elements from both x and y. function no yes
deepmerge.all(arrayOfObjects, [options]) Merges any number of objects into a single result object. function no yes

遗留问题

其他

开源协议

本项目基于 The MIT License (MIT) ,请自由地享受和参与开源。