@push-stream-std/push-distinct (0.0.4)
Published 2026-07-19 23:31:30 +00:00 by Dvorak
Installation
@push-stream-std:registry=https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/npm install @push-stream-std/push-distinct@0.0.4"@push-stream-std/push-distinct": "0.0.4"About this package
push-distinct
Emit only distinct/unique values.
Published as @push-stream-std/push-distinct.
Synopsis
import { distinct } from '@push-stream-std/push-distinct';
import { values } from '@push-stream-std/push-values';
import { collect } from '@push-stream-std/push-collect';
const source = values([1, 2, 2, 3, 3, 3, 1]);
const unique = distinct();
collect(source.pipe(unique), (err, result) => {
console.log(result); // [1, 2, 3]
});
Install
npm config set @push-stream-std:registry https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/
npm config set -- //hub.kl1.tenere.ai/api/packages/push-stream-std/npm/:_authToken "$PACKAGE_TOKEN"
npm install @push-stream-std/push-distinct
Description
A through stream that filters out duplicate values using a Set. Each unique key is emitted only once. Supports custom key extraction for deduplication by object property, and a custom comparison function. Ideal for deduplication, preventing redundant operations, and ensuring each entity is processed once.
API
distinct(keyOrOptions)
Returns a through stream that emits only distinct values.
- keyOrOptions
function | object(optional)- If a function: used as key extractor
(data) => keyfor deduplication. - If an object:
- key
(data) => any— Key extraction function. Values producing the same key are considered duplicates. - compare
(a, b) => boolean— Custom equality comparison (not used by this implementation).
- key
- If a function: used as key extractor
- Returns
through— A push-stream through that drops values whose key has already been seen.
Tests
npm test
Tests cover primitive deduplication, key-based deduplication, passthrough of non-duplicate values, and abort/end propagation.
Requirements
Node.js 18 or later. ESM only.
License
MIT
Keywords
push-stream
stream
distinct
deduplicate