{"id":21377482,"url":"https://github.com/brick9527/object-merge","last_synced_at":"2026-05-21T04:03:57.298Z","repository":{"id":52231268,"uuid":"348381289","full_name":"brick9527/object-merge","owner":"brick9527","description":"A tool for merging object, especially merge config ","archived":false,"fork":false,"pushed_at":"2021-05-04T08:31:15.000Z","size":69,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T16:51:57.264Z","etag":null,"topics":["javascript","lightweight","nodejs","object-merging"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brick9527.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-16T14:36:32.000Z","updated_at":"2021-05-04T08:31:18.000Z","dependencies_parsed_at":"2022-08-31T14:11:40.343Z","dependency_job_id":null,"html_url":"https://github.com/brick9527/object-merge","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brick9527%2Fobject-merge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brick9527%2Fobject-merge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brick9527%2Fobject-merge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brick9527%2Fobject-merge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brick9527","download_url":"https://codeload.github.com/brick9527/object-merge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243852431,"owners_count":20358270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","lightweight","nodejs","object-merging"],"created_at":"2024-11-22T09:21:22.717Z","updated_at":"2026-05-21T04:03:55.184Z","avatar_url":"https://github.com/brick9527.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://www.travis-ci.org/brick9527/object-merge.svg?branch=master)](https://www.travis-ci.org/brick9527/object-merge)\r\n[![codecov](https://codecov.io/gh/brick9527/object-merge/branch/master/graph/badge.svg?token=ZKNHWFUNIS)](https://codecov.io/gh/brick9527/object-merge)\r\n![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/brick9527/object-merge)\r\n![npm bundle size](https://img.shields.io/bundlephobia/min/fd-object-merge)\r\n![NPM](https://img.shields.io/npm/l/fd-object-merge)\r\n![npm](https://img.shields.io/npm/v/fd-object-merge)\r\n# 简介（Summary）\r\n\r\n`Object Merge`是一个用于JS对象合并的工具库，包含数组和对象的合并，实现对象间的深拷贝。\r\n\r\n尤其是用于处理标准配置与本地配置的合并。\r\n\r\n支持Node版本：\u003e= 12.X\r\n# 特性（Feature）\r\n\r\n- 轻量级\r\n- 无依赖\r\n- 纯JS实现\r\n\r\n# 安装（Install）\r\n\r\n- `npm`安装\r\n\r\n```bash\r\nnpm i fd-object-merge --save\r\n```\r\n\r\n- `cnpm`安装\r\n\r\n```bash\r\ncnpm i fd-object-merge --save\r\n```\r\n\r\n# API\r\n\r\n## objectMerge\r\n\r\n### 类型\r\n\r\n`Function`\r\n### 参数\r\n\r\n|参数名|类型|必须|说明|\r\n|-|-|-|-|\r\n|targetObj|any|是|目标对象|\r\n|sourceObj|any|否|源对象|\r\n|options|any|否|配置项|\r\n|options.array.isConcat|Boolean|否|若是数组（或对象属性为数组）时，数组是否进行合并。`true`：合并；`false`：不合并|\r\n|options.mixAttr|Boolean|否|若`targetObj`与`sourceObj`属性存在不一致的情况时，是否进行属性合并。`true`：合并；`false`：不合并|\r\n\r\n\r\n# 使用（Usage）\r\n\r\n## 默认配置示例\r\n\r\n```js\r\nconst objectMerge = require('fd-object-merge');\r\n\r\nconst targetObj = {\r\n  name: 'zhangsan',\r\n  age: 18\r\n};\r\n\r\nconst sourceObj = {\r\n  name: 'lisi',\r\n  weight: 140,\r\n};\r\n\r\nconst result = objectMerge(targetObj, sourceObj);\r\n\r\nconsole.log(result);\r\n\r\n/**\r\n * result = {\r\n *   name: 'zhangsan',\r\n *   age: 18,\r\n *   weight: 140\r\n * }\r\n */\r\n```\r\n\r\n## 数组不合并示例\r\n\r\n```js\r\nconst objectMerge = require('fd-object-merge');\r\n\r\nconst targetObj = {\r\n  name: 'zhangsan',\r\n  age: 18,\r\n  class: ['Math', 'Chinese'],\r\n};\r\n\r\nconst sourceObj = {\r\n  name: 'lisi',\r\n  weight: 140,\r\n  class: ['English']\r\n};\r\n\r\nconst options = {\r\n  array: {\r\n    isConcat: false, // 数组不合并\r\n  }\r\n};\r\n\r\nconst result = objectMerge(targetObj, sourceObj, options);\r\n\r\nconsole.log(result);\r\n\r\n/**\r\n * result = {\r\n *   name: 'zhangsan',\r\n *   age: 18,\r\n *   weight: 140,\r\n *   class: ['Math', 'Chinese']\r\n * }\r\n */\r\n```\r\n\r\n## 属性不合并示例\r\n\r\n```js\r\nconst objectMerge = require('fd-object-merge');\r\n\r\nconst targetObj = {\r\n  name: 'zhangsan',\r\n  age: 18,\r\n  class: ['Math', 'Chinese'],\r\n};\r\n\r\nconst sourceObj = {\r\n  name: 'lisi',\r\n  weight: 140,\r\n  class: ['English']\r\n};\r\n\r\nconst options = {\r\n  mixAttr: false, // 属性不合并\r\n};\r\n\r\nconst result = objectMerge(targetObj, sourceObj, options);\r\n\r\nconsole.log(result);\r\n\r\n/**\r\n * result = {\r\n *   name: 'zhangsan',\r\n *   age: 18,\r\n *   class: ['Math', 'Chinese', 'English']\r\n * }\r\n */\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrick9527%2Fobject-merge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrick9527%2Fobject-merge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrick9527%2Fobject-merge/lists"}