🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@jest/diff-sequences

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jest/diff-sequences

Compare items in two sequences to find a longest common subsequence

30.0.1
latest
Source
npm
Version published
Weekly downloads
2.2M
137.06%
Maintainers
5
Weekly downloads
 
Created

What is @jest/diff-sequences?

@jest/diff-sequences is a utility package used to efficiently compare sequences, such as arrays or strings, to find differences between them. It is particularly useful in testing scenarios where you need to assert the differences between expected and actual outputs.

What are @jest/diff-sequences's main functionalities?

Diffing Sequences

This feature allows you to compare two sequences and find the differences between them. The code sample demonstrates how to use the diffSequences function to compare two arrays and output the differences and commonalities.

const diffSequences = require('@jest/diff-sequences');

const a = [1, 2, 3, 4, 5];
const b = [1, 2, 4, 5, 6];

const result = [];
diffSequences(a.length, b.length, (indexA, indexB) => a[indexA] === b[indexB], (nCommon, aStart, bStart) => {
  result.push({ type: 'common', aStart, bStart, nCommon });
}, (nCommon, aStart, bStart) => {
  result.push({ type: 'different', aStart, bStart, nCommon });
});

console.log(result);

Other packages similar to @jest/diff-sequences

Keywords

fast

FAQs

Package last updated on 18 Jun 2025

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