New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

turbo-diff

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turbo-diff

A fast and small diff library for js/json data

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

A diff library for deep diff js/json object/array.

With 🚀 very fast diff speed (especially in array diff), 📦 tiny size (< 500b), 0 dependents, typescript support.

ts license mini zipped size dependents coverage tree-shaking support npm version

[English / 中文]

✨ Features

  • 🚀 Faster then other object diff libs, and the amazing array diff speed
  • 🛡 Build with typescript, fully support types
  • 🌐 Support all special type object deep diff
  • 📦 Lightweight and tree shaking support
  • 🌎 Support web, Node and workers

🎬 Quick start

  • Install
npm i turbo-diff
  • Usage

Import the lib and call with your objects you want to do diff.

import diff from 'turbo-diff';

console.log(diff({ foo: 'bar' }, { foo: 'bar', newKey: 'value' }));

🪞 Interface

Generic support.

interface Diff<T = any> {
    type: 'ADD' | 'REMOVE' | 'CHANGE';
    path: (string | number)[];
    old?: T;
    new?: T;
}
declare const diff: <T = any, TObj = Record<string, T> | T[]>(oldObj: TObj, newObj: TObj) => Diff<any>[];

😼 Playground

Edit playground: turbo-diff

🚀 Benchmark

  • With small object
"name""ops""margin""percentSlower"
"diff"565620.5698.88
"deep-diff"4336940.3191.4
"deep-object-diff"11493950.3577.2
"jsdiff"576850.3698.86
"microdiff"44000200.412.73
"microdiff-without-cyclesFix"43822060.3913.08
"turbo-diff"50417253.060
  • With big object
"name""ops""margin""percentSlower"
"diff"0.092.27100
"deep-diff"3911.8850.388.24
"deep-object-diff"35.3050.3199.89
"jsdiff"0.0890.53100
"microdiff"28992.7080.5112.82
"microdiff-without-cyclesFix"29038.5950.3512.68
"turbo-diff"33256.9280.40
  • With big object(deep 4, property count 10)
"name""ops""margin""percentSlower"
"diff"0.02011.32100
"deep-diff"364.47730.468.82
"deep-object-diff"360.83540.4669.13
"jsdiff"0.022.02100
"microdiff"902.04450.3822.84
"microdiff-without-cyclesFix"1021.04410.3312.66
"turbo-diff"1169.03660.330
  • With deeply nested object
"name""ops""margin""percentSlower"
"diff"91920.3599.03
"deep-diff"1639210.2882.79
"deep-object-diff"3302960.4165.32
"jsdiff"90500.3299.05
"microdiff"6448670.3532.3
"microdiff-without-cyclesFix"8171690.4714.21
"turbo-diff"9525160.30
  • With simple array
"name""ops""margin""percentSlower"
"diff"376560.3798.71
"deep-diff"3372570.3688.43
"deep-object-diff"2784280.3990.44
"jsdiff"382660.2898.69
"microdiff"16109100.4444.71
"microdiff-without-cyclesFix"15851050.3845.6
"turbo-diff"29137080.370
  • With simple array(place short array as newObject)
"name""ops""margin""percentSlower"
"diff"386560.3198.54
"deep-diff"3401880.8187.15
"deep-object-diff"2899630.3489.05
"jsdiff"393850.9398.51
"microdiff"17847440.4832.58
"microdiff-without-cyclesFix"17867820.3132.51
"turbo-diff"26473320.370

Keywords

diff

FAQs

Package last updated on 25 Dec 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