Emits unique values, with optional key selector.
import {pipe, distinct} from 'iter-ops';const i = pipe( [1, 1, 1, 2, 2, 2, 3, 3], distinct() // selector not needed for simple types);console.log(...i); //=> 1, 2, 3 Copy
import {pipe, distinct} from 'iter-ops';const i = pipe( [1, 1, 1, 2, 2, 2, 3, 3], distinct() // selector not needed for simple types);console.log(...i); //=> 1, 2, 3
With optional selector function:
import {pipe, distinct} from 'iter-ops';const i = pipe( [{a: 1}, {a: 1}, {a: 2}, {a: 2}], distinct(v => v.a));console.log(...i); //=> {a: 1}, {a: 2} Copy
import {pipe, distinct} from 'iter-ops';const i = pipe( [{a: 1}, {a: 1}, {a: 2}, {a: 2}], distinct(v => v.a));console.log(...i); //=> {a: 1}, {a: 2}
Optional
Emits unique values, with optional key selector.
With optional selector function: