1.1.0 • Published 5 years ago

unique-iterable v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

unique-iterable

Filters an iterable object so it doesn’t yield the same value more than once.

Optionally lets you set a numeric limit on total unique values yielded.

Installation

Requires Node.js 7.0.0 or above.

npm i unique-iterable

API

The module exports a single function.

Parameters

  1. Bindable: iter (iterable): The iterable whose values should be filtered for duplicates.
  2. Object argument:
    • Optional: limit (integer): The maximum number of unique items to yield. Defaults to Infinity.

Return Value

An iterable object that will iterate any given value only once.

Example

const uniqueIterable = require('unique-iterable')
const u = uniqueIterable([1, 1, 2, 2])
u.next().value // 1
u.next().value // 2
u.next().done // true

Here is the above example repeated with a limit argument:

const uniqueIterable = require('unique-iterable')
const u = uniqueIterable([1, 1, 2, 2], {limit: 1})
u.next().value // 1
u.next().done // true

Related Projects

1.1.0

5 years ago

1.0.0

6 years ago