New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

microdiff

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

microdiff - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

dist/index.d.cts

3

dist/index.js

@@ -25,4 +25,3 @@ const richTypes = { Date: true, RegExp: true, String: true, Number: true };

(!options.cyclesFix || !_stack.includes(objKey))) {
const nestedDiffs = diff(objKey, newObjKey, options, options.cyclesFix ? _stack.concat([objKey]) : []);
diffs.push.apply(diffs, nestedDiffs.map((difference) => {
diffs.push.apply(diffs, diff(objKey, newObjKey, options, options.cyclesFix ? _stack.concat([objKey]) : []).map((difference) => {
difference.path.unshift(path);

@@ -29,0 +28,0 @@ return difference;

{
"name": "microdiff",
"version": "1.4.0",
"version": "1.5.0",
"description": "Small, fast, zero dependency deep object and array comparison",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"default": "./dist/index.js"
"require": "./dist/index.cjs"
},
"scripts": {
"build": "tsc --module CommonJS && cd dist && mv \"index.js\" \"index.cjs\" && cd ../ && tsc --module es2020 && npx prettier -w dist/*",
"build": "tsc --module CommonJS && mv \"dist/index.js\" \"dist/index.cjs\" && mv \"dist/index.d.ts\" \"dist/index.d.cts\" && tsc --module es2020 && prettier -w dist/*",
"test": "npm run build && node --test ./tests/*",
"bench": "npm run build && node bench.js",
"bench": "npm run build && node --expose-gc bench.js",
"prepublish": "npm run build"

@@ -31,6 +29,7 @@ },

"deep-object-diff": "^1.1.9",
"diff": "^5.2.0",
"picocolors": "^1.0.0",
"prettier": "^3.2.5",
"typescript": "^5.4.2"
"diff": "^7.0.0",
"mitata": "^1.0.19",
"picocolors": "^1.1.1",
"prettier": "^3.4.1",
"typescript": "^5.7.2"
},

@@ -37,0 +36,0 @@ "type": "module",

@@ -5,5 +5,4 @@ <div align="center">

Microdiff is a tiny (currently <1kb), fast, zero dependency object and array comparison library. It is significantly faster than most other deep comparison libraries, and has full TypeScript support.
Microdiff is a tiny (<1kb), fast, zero dependency object and array comparison library. It is significantly faster than most other deep comparison libraries, and has full TypeScript support.
> 💡 I recommend reading this blog post:

@@ -21,3 +20,3 @@ >

- 📦 Extremely lightweight, <1kb minified
- 🌎 Supports Deno, Node, the web, and even service workers. Also comes with built-in Typescript types
- 🌎 Supports Deno, Node, Bun, the web, and even service workers. Also comes with built-in Typescript types
- 🔰 Very easy to use, having just a single `diff()` function

@@ -76,24 +75,21 @@ - 📅 Full support for objects like `new Date()` and `new RegExp()`

```
Benchmarks: Small object
deep-diff: 17929ns - 409% slower
deep-object-diff: 10763ns - 206% slower
jsdiff: 79700ns - 2164% slower
microdiff: 3520ns - Fastest
Benchmarks: Large Object
deep-diff: 272887ns - 259% slower
deep-object-diff: 160019ns - 111% slower
jsdiff: 1688294ns - 2123% slower
microdiff: 75934ns - Fastest
Geometric mean of time per operation relative to Microdiff (no cycles) (100%==equal time, lower is better)
microdiff (no cycles): 100%
microdiff: 149%
deep-diff: 197%
deep-object-diff: 288%
jsDiff: 1565%
```
These benchmarks are currently only for one small object and a very large object, so they might not be accurate. I will be working on creating benchmarks with more varying types.
These results are from a suite of benchmarks matching real world use cases of multiple open-source repos using various diffing algorithm, running under Node 22.12.0 on a Ryzen 7950x clocked at ~4.30 GHz. The benchmarks are run through [mitata](https://github.com/evanwashere/mitata) to minimize random variation and time most accurately. You can view the full benchmark code in [bench.js](https://github.com/AsyncBanana/microdiff/blob/master/bench.js) and the benchmarks themselves at [benchmarks/applied](https://github.com/AsyncBanana/microdiff/tree/master/benchmarks/applied).
Of course, [these benchmarks should be taken with a grain of salt](https://byteofdev.com/posts/javascript-benchmarking-mess/) due to the inherent errors present in benchmarking JavaScript, but if you want to run them on your own computer in your own runtime/setup, run `bench.js`.
# Contributing
Thanks for helping the project out! Contributing is pretty simple. Fork the repository (if you need more information on how to do this, check out [this GitHub guide](https://docs.github.com/en/get-started/quickstart/contributing-to-projects)), clone it to your computer, and start programming! To compile the program, run `npm run build` (replace `npm` with `pnpm` or `yarn` if you are using one of those). This will create CommonJS and ESM modules in `/dist`.
To benchmark microdiff, you can run `npm run bench`. This will automatically build Microdiff and run a benchmarking program comparing microdiff to other common diffing libraries.
Thanks for helping the project out! Contributing is pretty simple. Fork the repository (if you need more information on how to do this, check out [this GitHub guide](https://docs.github.com/en/get-started/quickstart/contributing-to-projects)), clone it to your computer, and start programming! To compile the program, run `npm run build` (replace `npm` with `pnpm` or `yarn` if you are using one of those). This will create CommonJS and ESM modules in `/dist`.
To benchmark microdiff, you can run `npm run bench`. This will automatically build Microdiff and run a benchmarking program comparing microdiff to other common diffing libraries.
Finally, Microdiff has an extensive test suite which you should take advantage of. To make sure everything is working correctly, you can run `npm run test`. `npm run test` builds the project and then runs the entire test suite on the new version. If you are fixing a bug, be sure to add a test for that.
Also, make sure you read the [Code of Conduct](https://github.com/AsyncBanana/microdiff/blob/master/CODE_OF_CONDUCT.md) before contributing.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc