Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "iter/dedupe-by/docs/types/index.d"

Index

Type aliases

Binary

Binary: (curr: any, sprev: any) => any

Indicates whether an iterated value is a "duplicate".

param

current source iterated value

param

previous source iterated value

returns

resolved value

Type declaration

    • (curr: any, sprev: any): any
    • Parameters

      • curr: any
      • sprev: any

      Returns any

Callback

Indicates whether an iterated value is a "duplicate".

param

current source iterated value

param

previous iterated value

param

iteration index (zero-based)

param

previous resolved value

returns

resolved value

Iterator

Iterator: Iter | IterableIterator

Nullary

Nullary: () => any

Indicates whether an iterated value is a "duplicate".

returns

resolved value

Type declaration

    • (): any
    • Returns any

Quaternary

Quaternary: (curr: any, sprev: any, dprev: any, index: number) => any

Indicates whether an iterated value is a "duplicate".

param

current source iterated value

param

previous source iterated value

param

previous downstream iterated value

param

source iteration index (zero-based)

returns

resolved value

Type declaration

    • (curr: any, sprev: any, dprev: any, index: number): any
    • Parameters

      • curr: any
      • sprev: any
      • dprev: any
      • index: number

      Returns any

Quinary

Quinary: (curr: any, sprev: any, dprev: any, index: number, acc: any) => any

Indicates whether an iterated value is a "duplicate".

param

current source iterated value

param

previous source iterated value

param

previous downstream iterated value

param

source iteration index (zero-based)

param

previous resolved value

returns

resolved value

Type declaration

    • (curr: any, sprev: any, dprev: any, index: number, acc: any): any
    • Parameters

      • curr: any
      • sprev: any
      • dprev: any
      • index: number
      • acc: any

      Returns any

Ternary

Ternary: (curr: any, sprev: any, dprev: any) => any

Indicates whether an iterated value is a "duplicate".

param

current source iterated value

param

previous source iterated value

param

previous downstream iterated value

returns

resolved value

Type declaration

    • (curr: any, sprev: any, dprev: any): any
    • Parameters

      • curr: any
      • sprev: any
      • dprev: any

      Returns any

Unary

Unary: (curr: any) => any

Indicates whether an iterated value is a "duplicate".

param

current source iterated value

returns

resolved value

Type declaration

    • (curr: any): any
    • Parameters

      • curr: any

      Returns any

Functions

Export assignment iterDedupeBy

  • Returns an iterator which removes consecutive values that resolve to the same value according to a provided function.

    Notes

    • If an environment supports Symbol.iterator and a provided iterator is iterable, the returned iterator is iterable.

    Parameters

    • iterator: Iterator

      input iterator

    • fcn: Callback

      function indicating whether an iterated value is a "duplicate"

    Returns Iterator

    iterator

    Example

    var array2iterator = require( `@stdlib/array/to-iterator` );
    
    function fcn( v ) {
        return v;
    }
    
    var arr = array2iterator( [ 1, 1, 2, 3, 3 ] );
    var iter = iterDedupeBy( arr, fcn );
    
    var v = iter.next().value;
    // returns 1
    
    v = iter.next().value;
    // returns 2
    
    v = iter.next().value;
    // returns 3
    
    // ...
  • Returns an iterator which removes consecutive values that resolve to the same value according to a provided function.

    Notes

    • If an environment supports Symbol.iterator and a provided iterator is iterable, the returned iterator is iterable.
    throws

    limit must be a positive integer

    Parameters

    • iterator: Iterator

      input iterator

    • limit: number

      number of allowed consecutive duplicates

    • fcn: Callback

      function indicating whether an iterated value is a "duplicate"

    Returns Iterator

    iterator

    Example

    var array2iterator = require( `@stdlib/array/to-iterator` );
    
    function fcn( v ) {
        return v;
    }
    
    var arr = array2iterator( [ 1, 1, 2, 3, 3 ] );
    var iter = iterDedupeBy( arr, 1, fcn );
    
    var v = iter.next().value;
    // returns 1
    
    v = iter.next().value;
    // returns 2
    
    v = iter.next().value;
    // returns 3
    
    // ...