
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
record-diff
Advanced tools
> 一个对比两个记录集的差异的工具包,根据指定 keyName 来对比两条记录,并可分析出差异路径。 > - 可设置忽略某个键值 > - 支持是否全等对比 > - 输出差异节点路径 > - 细分变更类型,按新增,修改,删除
一个对比两个记录集的差异的工具包,根据指定 keyName 来对比两条记录,并可分析出差异路径。
- 可设置忽略某个键值
- 支持是否全等对比
- 输出差异节点路径
- 细分变更类型,按新增,修改,删除
npm i record-diff
const recordDiff = require('record-diff');
const a1 = [{id: 1 x: 'sth here', y: 'yy'}, {id: 2, xx: 1}];
const b1 = [{id: 1, x: 'sth changed', z: 'zz'}, {id: 3, xxx: 2}];
console.log(recordDiff(a1, b1, 'id'));
{
"changed": [ // 被变更的记录
{
"id": 1,
"x": "sth changed",
"z": "zz"
}
],
"changedDetails": [ // 被变更记录的详细路径节点
{
"1": {
"$unset": {
"y": true
},
"$set": {
"x": "sth changed",
"z": "zz"
}
}
}
],
"added": [ // 新增的记录
{
"id": 3,
"xxx": 2
}
],
"removed": [ // 移除的记录
{
"id": 2,
"xx": 1
}
]
}
recordDiff(beforeRecord, afterRecord, keyName, options);
Array被对比的数据集
Array新的数据集
String|Number每条记录中的主键,用于对于
strictEqual = true boolean
是否使用严格匹配模式来对比每个值,即使用 ===
ignoreKey string
忽略对比某个 key
stringifyEqual = false boolean
是否把值都转为 String 值来对比
inc = false boolean
是否对比差值,如果为 true,则尝试转换值为数值类型,并计算差值,会在 changedDetails $inc 字段中体现。
FAQs
> 一个对比两个记录集的差异的工具包,根据指定 keyName 来对比两条记录,并可分析出差异路径。 > - 可设置忽略某个键值 > - 支持是否全等对比 > - 输出差异节点路径 > - 细分变更类型,按新增,修改,删除
The npm package record-diff receives a total of 0 weekly downloads. As such, record-diff popularity was classified as not popular.
We found that record-diff demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.