All Projects → Kikobeats → hyperdiff

Kikobeats / hyperdiff

Licence: MIT license
Find common, removed and added element between two collections.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to hyperdiff

unikmer
Toolkit for k-mer with taxonomic information
Stars: ✭ 46 (+228.57%)
Mutual labels:  intersection, difference
speech-recognition-evaluation
Evaluate results from ASR/Speech-to-Text quickly
Stars: ✭ 25 (+78.57%)
Mutual labels:  comparison, difference
bentley-ottmann
simple Java implementation of Bentley-Ottmann sweep line algorithm for listing all intersections in a set of line segments
Stars: ✭ 16 (+14.29%)
Mutual labels:  intersection
clipper
Implementation for the clipper library in rhino and grasshopper.
Stars: ✭ 55 (+292.86%)
Mutual labels:  intersection
neptune-client
📒 Experiment tracking tool and model registry
Stars: ✭ 348 (+2385.71%)
Mutual labels:  comparison
json-path-comparison
Comparison of the different implementations of JSONPath and language agnostic test suite.
Stars: ✭ 64 (+357.14%)
Mutual labels:  comparison
MessengerComparison
Project aimed at providing thorough comparison of Telegram, Viber and WhatsApp.
Stars: ✭ 28 (+100%)
Mutual labels:  comparison
illogical
A micro conditional javascript engine used to parse the raw logical and comparison expressions, evaluate the expression in the given data context, and provide access to a text form of the given expressions.
Stars: ✭ 16 (+14.29%)
Mutual labels:  comparison
npm-vs-yarn
Compare npm vs yarn
Stars: ✭ 36 (+157.14%)
Mutual labels:  comparison
elm-javascript-haskell-equivalents
Comparison of similar functions across Elm, Javascript, and Haskell
Stars: ✭ 31 (+121.43%)
Mutual labels:  comparison
language-benchmarks
A simple benchmark system for compiled and interpreted languages.
Stars: ✭ 21 (+50%)
Mutual labels:  comparison
xdem
Analysis of digital elevation models (DEMs)
Stars: ✭ 50 (+257.14%)
Mutual labels:  comparison
octoclairvoyant-webapp
Compare GitHub changelogs across multiple releases in a single view.
Stars: ✭ 45 (+221.43%)
Mutual labels:  comparison
intersection-wasm
Mesh-Mesh and Triangle-Triangle Intersection tests based on the algorithm by Tomas Akenine-Möller
Stars: ✭ 17 (+21.43%)
Mutual labels:  intersection
version-compare
↔️ Rust library to easily compare version strings. Mirror from https://gitlab.com/timvisee/version-compare
Stars: ✭ 32 (+128.57%)
Mutual labels:  comparison
won
A new way to see HTML Web Pages
Stars: ✭ 15 (+7.14%)
Mutual labels:  comparison
SecureUnionID
Secure ECC-based DID intersection in Go, Java and C.
Stars: ✭ 19 (+35.71%)
Mutual labels:  intersection
microdiff
A fast, zero dependency object and array comparison library. Significantly faster than most other deep comparison libraries and has full TypeScript support.
Stars: ✭ 3,138 (+22314.29%)
Mutual labels:  comparison
Seiyuu.moe
A webpage searching for collaborate works between seiyuu.
Stars: ✭ 15 (+7.14%)
Mutual labels:  comparison
interval
This PHP library provides some tools to handle intervals. For instance, you can compute the union or intersection of two intervals.
Stars: ✭ 25 (+78.57%)
Mutual labels:  intersection

hyperdiff

Last version Coverage Status NPM Status

Find common, removed and added element between two collections.

Install

$ npm install hyperdiff --save

Usage

Using a flat Array:

const diff = require('hyperdiff')

const result = diff(
  [1, 2, 3, 4, 5, 6],
  [1, 2, 4, 5, 6, 0, 9, 10]
)

console.log(result)
// {
//   added: [ 0, 9, 10 ],
//   removed: [ 3 ],
//   common: [ 1, 2, 4, 5, 6 ]
// }

Using an Array of Object's (in this case you need to provide the unique id):

const diff = require('hyperdiff')
const result = diff(
  [
    { id: 1, name: 'a' },
    { id: 2, name: 'b' },
    { id: 3, name: 'c' },
    { id: 4, name: 'd' },
    { id: 5, name: 'e' }
  ],
  [
    { id: 1, name: 'a' },
    { id: 2, name: 'b' },
    { id: 7, name: 'e' }
  ],
  'id'
)

console.log(result)
// {
//   added: [ { id: 7, name: 'e' } ],
//   removed: [ { id: 3, name: 'c' }, { id: 4, name: 'd' }, { id: 5, name: 'e' } ],
//   common: [ { id: 1, name: 'a' }, { id: 2, name: 'b' } ]
// }

It's also support multiple properties as id or provide a function.

Benchmark

❯ node bench.js
simpleArrayDiff*1000: 143.742ms
hyperDiff*1000: 80.234ms
simpleArrayDiff*1000: 143.405ms
hyperDiff*1000: 75.803ms

API

hyperdiff(orig, dist, [ids])

orig

Required
Type: array

First array for be compared.

dist

Required
Type: array

Second array for be compared. Notes the results are modeled from the second array.

ids

Type: string|array|function

In the case that you provide an Array of Object's, you need to specify the key's to be used as id.

Related

  • redis-diff - Perform a diff comparison backed by redis.

License

MIT © Kiko Beats.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].