Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

disparity

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

disparity

Colorized string diff ideal for text/code that spans through multiple lines

  • 3.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is disparity?

The disparity npm package is a tool for generating and applying diffs between text files. It is useful for comparing two versions of a file and highlighting the differences between them.

What are disparity's main functionalities?

Generate Unified Diff

This feature allows you to generate a unified diff between two strings. The code sample demonstrates how to use disparity to compare two versions of a text and output the differences in a unified diff format.

const disparity = require('disparity');
const oldText = 'Hello World!';
const newText = 'Hello Brave New World!';
const diff = disparity.unified(oldText, newText);
console.log(diff);

Apply Diff

This feature allows you to apply a diff to a string to generate a new version of the text. The code sample shows how to apply a previously generated diff to an old version of a text to produce the new version.

const disparity = require('disparity');
const oldText = 'Hello World!';
const diff = '--- a
+++ b
@@ -1 +1 @@
-Hello World!
+Hello Brave New World!';
const newText = disparity.apply(oldText, diff);
console.log(newText);

Other packages similar to disparity

Keywords

FAQs

Package last updated on 20 Jan 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