Skip to content

Commit d1e5d70

Browse files
fix group test
modify group test so that it works with group iterators
1 parent a37d6a2 commit d1e5d70

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/map/group.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ import { iter } from '..' ;
44
* Yields elements of the input iterable by grouping them into tuples
55
* consecutive elements from the same equivalence class.
66
*
7+
* @example
8+
* // A B C D A B
9+
* list( map( ( k , g ) => k , groupby('AAAABBBCCDAABBB') ) )
10+
*
11+
* @example
12+
* // AAAA BBB CC D
13+
* list( map( ( k , g ) => list( g ) , groupby('AAAABBBCCD') ) )
14+
*
715
* @param {Function} key - The function used to determine the equivalence class
816
* of an element.
917
* @param {Iterable} iterable - The input iterable.

test/src/map/group.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import test from 'ava' ;
22

3-
import { list , group } from '../../..' ;
3+
import { list , map , group } from '../../..' ;
44
import { identity } from 'aureooms-js-operator' ;
55

66
test( "group", t => {
77

88
const x = ( key, iterable, expected ) => {
99

10-
t.deepEqual( list( group( key , iterable ) ), expected );
10+
t.deepEqual( list( map( ( [ k , g ] ) => [ k , list( g ) ] , group( key , iterable ) ) ), expected );
1111

1212
};
1313

@@ -56,3 +56,6 @@ test( "group", t => {
5656

5757
});
5858

59+
//test( 'group for infinite sequence of 0' , t => {
60+
61+
//} );

0 commit comments

Comments
 (0)