sf-utils2 sf-utils2
版本v3.3.3-beta1
首页
  • 01.快速开始 🔥
  • 02.基础-Base
  • 03.对象-Object
  • 04.数组-Array
  • 05.方法-Function
  • 06.字符串-String
  • 07.数学-Math
  • 08.dom
  • 09.拓展
  • webpack5.x教程学习 (opens new window)
  • 例子
  • 教程 🔥
  • 例子配置
企业级后台模版 (opens new window)
版本v3.3.3-beta1
首页
  • 01.快速开始 🔥
  • 02.基础-Base
  • 03.对象-Object
  • 04.数组-Array
  • 05.方法-Function
  • 06.字符串-String
  • 07.数学-Math
  • 08.dom
  • 09.拓展
  • webpack5.x教程学习 (opens new window)
  • 例子
  • 教程 🔥
  • 例子配置
企业级后台模版 (opens new window)
  • 快速开始

  • 基础-Base

  • 对象-Object

    • 序言 👏
    • has【对象含有属性(功能更强大)】
    • hasOwn【对象含有属性(扩展)】
    • deepClone【深度克隆】
    • setPropPath【给每个对象设置路径节点名】
    • findPropPath【从对象中找到键名路径名】
    • get【获取对象属性值】🔥🔥🔥
    • flatten 【将对象进行扁平化】
    • readonly【定义只读属性】
    • def【定义不可枚举属性】
    • cache【内存缓存对象】
    • bus【发布订阅】🔥🔥🔥
    • merge 【合并对象】
    • deepMerge 【递归深合并对象】
      • 1.示例
      • 2.入参说明
      • 3.源码
    • transformObjectKeys【对象属性字段全部转成大写或者小写】
    • convertPropToLower【对象属性字段全部转成大写或者小写】
    • looseEqual【比较对象内部结构和数据】🔥🔥🔥
    • omit【忽略对象属性】
    • pick【取出对象属性】
  • 数组-Array✨✨✨

  • 方法-Function

  • 字符串-String

  • 数学-Math

  • 文件-Buffer

  • 节点-dom

  • 拓展

  • nodejs

目录

deepMerge 【递归深合并对象】

描述

深度(递归)合并对象 v3.0.6+,主要利用deepmerge (opens new window)

# 1.示例

import { deepMerge } from 'sf-utils2'

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'
    }
  ]
}

deepMerge(x, y) //

// 输出 output
const output = {
  foo: {
    bar: 3,
    baz: 4
  },
  array: [
    {
      does: 'work',
      too: [1, 2, 3]
    },
    {
      does: 'work',
      too: [4, 5, 6]
    },
    {
      really: 'yes'
    }
  ],
  quux: 5
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

# 2.入参说明

参数 说明 类型 是否必填
target 目标对象 Object、Array --------
source 原对象 Object、Array --------

# 3.源码

import _helperDeepMerge from '@/_helper/_helperDeepMerge'

/**
 * 深合并对象
 * @param {Object|Array} target 目标对象
 * @param {Object|Array} source 原对象
 * @return {Object|Array|any}
 */
function deepMerge(target, source) {
  return _helperDeepMerge(target, source)
}

export default deepMerge
1
2
3
4
5
6
7
8
9
10
11
12
13
上次更新: 2023/06/24, 19:35:48
merge 【合并对象】
transformObjectKeys【对象属性字段全部转成大写或者小写】

← merge 【合并对象】 transformObjectKeys【对象属性字段全部转成大写或者小写】→

Theme by Vdoing | Copyright © 2022-2025 bianpengfei
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
×