🪞 Minimalistic deep comparison.
This library takes 2 values (a left
and a right
) and returns an iterator
with all the differences between said values. The differences are represented by
3 kinds:
left
and existing right
.left
and right
values.left
and missing right
.As all Coven Engineering libraries, it has 100% test coverage and it's built in top of modern tech compatible with all JavaScript runtimes.
import { compare } from "@coven/compare"; compare("Coven")("Engineering"); // Yields { kind: "UPDATE", left: "Coven", right: "Engineering" } compare({ example: 13 })({ example: 42 }); // Yields { kind: "UPDATE", left: "13", right: "42", path: ["example"] } compare({ example: 13 })({}); // Yields { kind: "DELETE", left: "13", path: ["example"] }
Add Package
deno add jsr:@coven/compare
Import symbol
import * as compare from "@coven/compare";
---- OR ----
Import directly with a jsr specifier
import * as compare from "jsr:@coven/compare";
Add Package
npx jsr add @coven/compare
Import symbol
import * as compare from "@coven/compare";
Add Package
yarn dlx jsr add @coven/compare
Import symbol
import * as compare from "@coven/compare";
Add Package
pnpm dlx jsr add @coven/compare
Import symbol
import * as compare from "@coven/compare";
Add Package
bunx jsr add @coven/compare
Import symbol
import * as compare from "@coven/compare";