An open API service indexing awesome lists of open source software.

https://github.com/blackglory/extra-deduplicator

🌿 A data deduplication library
https://github.com/blackglory/extra-deduplicator

deno jsr-package library typescript

Last synced: about 1 month ago
JSON representation

🌿 A data deduplication library

Awesome Lists containing this project

README

          

# extra-deduplicator
A data deduplication library for Deno,
which is designed for extracting new data.

## Install
```sh
deno add jsr:@blackglory/deduplicator
```

## Usage
```ts
#!/usr/bin/env -S deno run --allow-all
import { Deduplicator } from 'jsr:@blackglory/deduplicator'

const deduplicator = await Deduplicator.create({ filename: 'dedup.db' })

const records = ['record-1', 'record-2']
const newRecords = await deduplicator.addAndDidff(records)
```

## API
```ts
interface IOptions {
filename?: string

hash?: (value: T) => JSONValue

shrink?: {
target?: number
threshold?: number
}
}

class Deduplicator {
static create(options?: IOptions): Promise>

add(values: T[]): Promise

diff(values: T[]): Promise
diffLast(value: T): Promise

addAndDiff(values: T[]): Promise
addAndDiffLast(value: T): Promise

close(): void
}
```