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

fast-diff

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-diff

Fast Javascript text diff

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17M
decreased by-0.55%
Maintainers
2
Weekly downloads
 
Created

What is fast-diff?

The fast-diff npm package is a JavaScript library that provides a fast and efficient way to compute the difference between two strings. It is commonly used to implement text comparison features, such as in diff tools or for highlighting changes in text documents.

What are fast-diff's main functionalities?

Compute Difference

This feature allows you to compute the difference between two strings. The function returns an array of tuples, where each tuple represents a part of the diff and its type (addition, deletion, or no change).

const diff = require('fast-diff');
const text1 = 'hello world';
const text2 = 'hello new world';
const changes = diff(text1, text2);
console.log(changes);

Customizable Diff Function

fast-diff allows you to customize the diff function by passing an optional cursor position to optimize the diff computation around that cursor location. This is useful for real-time editing applications.

const diff = require('fast-diff');
const text1 = 'goodbye world';
const text2 = 'goodbye cruel world';
const changes = diff(text1, text2, diff.EQUAL);
console.log(changes);

Other packages similar to fast-diff

Keywords

FAQs

Package last updated on 19 May 2023

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