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

microdiff

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

microdiff

Small, fast, zero dependency deep object and array comparison

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
165K
decreased by-9.12%
Maintainers
1
Weekly downloads
 
Created
Source

Microdiff

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.

Get started

First, install Microdiff

npm i microdiff

Then, simply import it and run it on two objects.

import diff from "microdiff";

const obj1 = {
	originalProperty: true,
};
const obj2 = {
	originalProperty: true,
	newProperty: "new",
};

console.log(diff(obj1, obj2));
// [{type: "CREATE", path: ["newProperty"], value: "new"}]

There are three different types of changes. CREATE, REMOVE, and CHANGE. The path property gives a path to the property in the new object (or the old object in the case of REMOVE). Each element in the array is a key to the next property a level deeper until you get to the property changed. The value property exists in types CREATE and CHANGE, and it contains the value of the property added/changed.

Keywords

FAQs

Package last updated on 02 Nov 2021

Did you know?

Socket

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.

Install

Related posts

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