1.0.2 • Published 3 years ago

@gen-x/uniq v1.0.2

Weekly downloads
2
License
MIT
Repository
-
Last release
3 years ago

@gen-x/uniq

The uniq utility makes sure that only uniq items are yielded in the pipeline.

import genX from '@gen-x/core'
import uniq from '@gen-x/uniq'

const iterate = genX(() => [1, 1, 2, 2], uniq())

for await (const x of iterate()) {
  console.info(x)
}

// 1
// 2

WARNING: This utility keeps state and could potentially cause a memory leak. It's wise to clean up when you're finished:

import genX from '@gen-x/core'
import uniq from '@gen-x/uniq'

const uniqueNumbers = uniq<number>()

const iterate = genX(() => [1, 1, 2, 2], uniqueNumbers)

for await (const x of iterate()) {
  console.info(x)
}

// 1
// 2

uniqueNumbers.clear()
1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago

0.0.0

4 years ago