Function
Static Public Summary | ||
public |
Yields elements of the input iterable by grouping them into tuples of a given size. |
|
public |
Yields elements of the input iterable by grouping them into tuples consecutive elements from the same equivalence class. |
Static Public
public * by(iterable: Iterable, n: Number): Iterator source
import by from '@iterable-iterator/group/src/by.js'
Yields elements of the input iterable by grouping them into tuples of a given size.
Params:
Name | Type | Attribute | Description |
iterable | Iterable | The input iterable. |
|
n | Number | The size of the yielded tuples. |
Return:
Iterator |
public * group(key: Function, iterable: Iterable): Iterator source
import group from '@iterable-iterator/group/src/group.js'
Yields elements of the input iterable by grouping them into tuples consecutive elements from the same equivalence class.
Params:
Name | Type | Attribute | Description |
key | Function | The function used to determine the equivalence class of an element. |
|
iterable | Iterable | The input iterable. |
Return:
Iterator |
Example:
// A B C D A B
list( map( ( [ k , g ] ) => k , group( x => x , 'AAAABBBCCDAABBB' ) ) )
// AAAA BBB CC D
list( map( ( [ k , g ] ) => list( g ) , group( x => x , 'AAAABBBCCD' ) ) )