@@ -29,37 +29,6 @@ var iterEmpty = require( '@stdlib/iter/empty' );
2929var iterIntersection = require ( './../lib' ) ;
3030
3131
32- // FUNCTIONS //
33-
34- function createIterator ( arr ) {
35- var len ;
36- var it ;
37- var i ;
38-
39- len = arr . length ;
40- i = - 1 ;
41-
42- it = { } ;
43- it . next = next ;
44-
45- return it ;
46-
47- function next ( ) {
48- var out ;
49- i += 1 ;
50- if ( i < len ) {
51- out = { } ;
52- out . value = arr [ i ] ;
53- out . done = ( i === len - 1 ) ;
54- return out ;
55- }
56- return {
57- 'done' : true
58- } ;
59- }
60- }
61-
62-
6332// TESTS //
6433
6534tape ( 'main export is a function' , function test ( t ) {
@@ -380,204 +349,6 @@ tape( 'the function returns an iterator which returns the intersection of three
380349 t . end ( ) ;
381350} ) ;
382351
383- tape ( 'the function returns an iterator protocol-compliant object (value+done)' , function test ( t ) {
384- var expected ;
385- var values1 ;
386- var values2 ;
387- var actual ;
388- var it1 ;
389- var it2 ;
390- var it ;
391- var i ;
392-
393- values1 = [ 4 , 2 , 4 ] ;
394- values2 = [ 1 , 3 , 4 ] ;
395- expected = [
396- {
397- 'value' : 4 ,
398- 'done' : false
399- } ,
400- {
401- 'done' : true
402- }
403- ] ;
404-
405- it1 = createIterator ( values1 ) ;
406- it2 = createIterator ( values2 ) ;
407-
408- it = iterIntersection ( it1 , it2 ) ;
409- t . equal ( it . next . length , 0 , 'has zero arity' ) ;
410-
411- actual = [ ] ;
412- for ( i = 0 ; i < expected . length ; i ++ ) {
413- actual . push ( it . next ( ) ) ;
414- }
415- t . deepEqual ( actual , expected , 'returns expected values' ) ;
416- t . end ( ) ;
417- } ) ;
418-
419- tape ( 'the function returns an iterator protocol-compliant object (value+done)' , function test ( t ) {
420- var expected ;
421- var values1 ;
422- var values2 ;
423- var actual ;
424- var it1 ;
425- var it2 ;
426- var it ;
427-
428- values1 = [ 4 , 2 ] ;
429- values2 = [ 1 , 3 ] ;
430- expected = [
431- {
432- 'done' : true
433- }
434- ] ;
435-
436- it1 = createIterator ( values1 ) ;
437- it2 = createIterator ( values2 ) ;
438-
439- it = iterIntersection ( it1 , it2 ) ;
440- t . equal ( it . next . length , 0 , 'has zero arity' ) ;
441-
442- actual = [ ] ;
443- actual . push ( it . next ( ) ) ;
444-
445- t . deepEqual ( actual , expected , 'returns expected values' ) ;
446- t . end ( ) ;
447- } ) ;
448-
449- tape ( 'the function returns an iterator which returns the intersection of two iterators (value+done)' , function test ( t ) {
450- var expected ;
451- var values1 ;
452- var values2 ;
453- var actual ;
454- var it1 ;
455- var it2 ;
456- var it ;
457- var i ;
458-
459- values1 = [ 2 , 1 , 2 , 1 , 1 , 4 ] ;
460- values2 = [ 4 , 4 , 3 , 2 , 1 ] ;
461- expected = [
462- {
463- 'value' : 2 ,
464- 'done' : false
465- } ,
466- {
467- 'value' : 1 ,
468- 'done' : false
469- } ,
470- {
471- 'value' : 4 ,
472- 'done' : false
473- } ,
474- {
475- 'done' : true
476- }
477- ] ;
478-
479- it1 = createIterator ( values1 ) ;
480- it2 = createIterator ( values2 ) ;
481-
482- it = iterIntersection ( it1 , it2 ) ;
483- t . equal ( it . next . length , 0 , 'has zero arity' ) ;
484-
485- actual = [ ] ;
486- for ( i = 0 ; i < expected . length ; i ++ ) {
487- actual . push ( it . next ( ) ) ;
488- }
489- t . deepEqual ( actual , expected , 'returns expected values' ) ;
490- t . end ( ) ;
491- } ) ;
492-
493- tape ( 'the function returns an iterator which returns the intersection of three iterators (value+done)' , function test ( t ) {
494- var expected ;
495- var values1 ;
496- var values2 ;
497- var values3 ;
498- var actual ;
499- var it1 ;
500- var it2 ;
501- var it3 ;
502- var it ;
503- var i ;
504-
505- values1 = [ 2 , 1 , 2 , 1 , 1 , 4 ] ;
506- values2 = [ 4 , 4 , 1 , 3 , 2 ] ;
507- values3 = [ 5 , 2 , 1 ] ;
508- expected = [
509- {
510- 'value' : 2 ,
511- 'done' : false
512- } ,
513- {
514- 'value' : 1 ,
515- 'done' : false
516- } ,
517- {
518- 'done' : true
519- }
520- ] ;
521-
522- it1 = createIterator ( values1 ) ;
523- it2 = createIterator ( values2 ) ;
524- it3 = createIterator ( values3 ) ;
525-
526- it = iterIntersection ( it1 , it2 , it3 ) ;
527- t . equal ( it . next . length , 0 , 'has zero arity' ) ;
528-
529- actual = [ ] ;
530- for ( i = 0 ; i < expected . length ; i ++ ) {
531- actual . push ( it . next ( ) ) ;
532- }
533- t . deepEqual ( actual , expected , 'returns expected values' ) ;
534- t . end ( ) ;
535- } ) ;
536-
537- tape ( 'the function returns an iterator which returns the intersection of two or more iterators (value+done)' , function test ( t ) {
538- var expected ;
539- var values1 ;
540- var values2 ;
541- var actual ;
542- var it1 ;
543- var it2 ;
544- var it ;
545- var i ;
546-
547- values1 = [ 2 , 1 , 2 , 1 , 1 , 4 ] ;
548- values2 = [ 4 , 4 , 3 , 2 , 1 , 5 ] ;
549- expected = [
550- {
551- 'value' : 2 ,
552- 'done' : false
553- } ,
554- {
555- 'value' : 1 ,
556- 'done' : false
557- } ,
558- {
559- 'value' : 4 ,
560- 'done' : false
561- } ,
562- {
563- 'done' : true
564- }
565- ] ;
566-
567- it1 = createIterator ( values1 ) ;
568- it2 = createIterator ( values2 ) ;
569-
570- it = iterIntersection ( it1 , it2 ) ;
571- t . equal ( it . next . length , 0 , 'has zero arity' ) ;
572-
573- actual = [ ] ;
574- for ( i = 0 ; i < expected . length ; i ++ ) {
575- actual . push ( it . next ( ) ) ;
576- }
577- t . deepEqual ( actual , expected , 'returns expected values' ) ;
578- t . end ( ) ;
579- } ) ;
580-
581352tape ( 'the returned iterator has a `return` method for closing an iterator (no argument)' , function test ( t ) {
582353 var rand1 ;
583354 var rand2 ;
0 commit comments