nora-natio avatar
Natio

record-diff

Pool

Detect added, changed and removed API records with deterministic SHA-256 snapshots, without persisting the original payloads.

$ lpm install @lpm.dev/nora-natio.record-diff
8 exportsTypeScript

Functions

canonicalJson
function canonicalJson(value: JsonValue): string
ParameterTypeDescription
value
JsonValue
fingerprint
function fingerprint(value: JsonValue): string
ParameterTypeDescription
value
JsonValue
createSnapshot
function createSnapshot<T>(records: T[], options?: Options<T>): Snapshot
ParameterTypeDescription
records
T[]
optionsoptional
Options<T>
diffRecords
function diffRecords<T>(previous: Snapshot | null, records: T[], options?: Options<T>): Diff<T>
ParameterTypeDescription
previous
Snapshot | null
records
T[]
optionsoptional
Options<T>

Interfaces

Snapshot
PropertyTypeDescription
version
1
algorithm
'sha256'
entries
Array<{ id: string; hash: string }>
Options<T>
PropertyTypeDescription
keyoptional
string | ((record: T) => string)
selectoptional
(record: T) => JsonValue
Diff<T>
PropertyTypeDescription
added
T[]
changed
T[]
removed
string[]
unchanged
string[]
snapshot
Snapshot

Types

JsonValue
type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue }
Unlimited AccessInstall as many Pool packages as you need.
Fund Real WorkEvery install you run sends revenue directly to the developer who built it.

Taxes calculated at checkout based on your location.

Version
1.0.0
Published
LicenseMIT
Size13.34 KiB
Files7
Node version>= 18
TypeScriptYes