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

@thi.ng/diff

Package Overview
Dependencies
Maintainers
1
Versions
184
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/diff

Customizable diff implementations for arrays (sequential) & objects (associative), with or without linear edit logs

  • 3.2.24
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
80
decreased by-63.8%
Maintainers
1
Weekly downloads
 
Created
Source

diff

npm version npm downloads Twitter Follow

This project is part of the @thi.ng/umbrella monorepo.

About

Customizable diff implementations for arrays (sequential) & objects (associative), with or without linear edit logs.

Status

STABLE - used in production

Installation

yarn add @thi.ng/diff
// ES module
<script type="module" src="https://unpkg.com/@thi.ng/diff?module" crossorigin></script>

// UMD
<script src="https://unpkg.com/@thi.ng/diff/lib/index.umd.js" crossorigin></script>

Package sizes (gzipped, pre-treeshake): ESM: 1.25 KB / CJS: 1.30 KB / UMD: 1.32 KB

Dependencies

API

Generated API docs

import { diffArray, DiffMode } from "@thi.ng/diff";

diffArray([1, 2, 3], [1, 2, 4], DiffMode.FULL);
// {
//     distance: 2,
//     adds: { 2: 4 },
//     dels: { 2: 3 },
//     const: { 0: 1, 1: 2 },
//     linear: [0, 0, 1,  0, 1, 2,  -1, 2, 3,  1, 2, 4]
// }

Breaking changes

2.0.0

The linear edit logs of both diffArray and diffObject are now returned as flat arrays, with each log entry consisting of 3 or 2 successive array items. This is to avoid allocation of various small arrays.

The order of optional args to both functions has been swapped to:

  • diffArray(old, new, mode?, equiv?)
  • diffObject(old, new, mode?, equiv?)

Authors

Karsten Schmidt

License

© 2016 - 2020 Karsten Schmidt // Apache Software License 2.0

Keywords

FAQs

Package last updated on 20 Jun 2020

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