Skip to content

Commit a8da456

Browse files
committed
Refactor to ignore iterator return values
1 parent ffc03db commit a8da456

File tree

2 files changed

+4
-127
lines changed

2 files changed

+4
-127
lines changed

lib/node_modules/@stdlib/iter/mapn/lib/main.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
2424
var isFunction = require( '@stdlib/assert/is-function' );
2525
var isIteratorLike = require( '@stdlib/assert/is-iterator-like' );
26-
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2726
var iteratorSymbol = require( '@stdlib/symbol/iterator' );
2827

2928

@@ -109,8 +108,8 @@ function iterMapN() {
109108
setReadOnly( iter, iteratorSymbol, factory );
110109
}
111110
}
111+
FLG = false;
112112
idx = -1;
113-
FLG = 0;
114113
i = 0;
115114
return iter;
116115

@@ -131,18 +130,11 @@ function iterMapN() {
131130
}
132131
args = [];
133132
idx += 1;
134-
FLG = 0;
135133
for ( i = 0; i < niter; i++ ) {
136134
v = iterators[ i ].next();
137135
if ( v.done ) {
138-
FLG += 1;
139-
if ( hasOwnProp( v, 'value' ) ) {
140-
args.push( v.value );
141-
continue;
142-
}
143-
return {
144-
'done': true
145-
};
136+
FLG = true;
137+
return v;
146138
}
147139
args.push( v.value );
148140
}
@@ -161,7 +153,7 @@ function iterMapN() {
161153
* @returns {Object} iterator protocol-compliant object
162154
*/
163155
function end( value ) {
164-
FLG = 1;
156+
FLG = true;
165157
if ( arguments.length ) {
166158
return {
167159
'value': value,

lib/node_modules/@stdlib/iter/mapn/test/test.js

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,6 @@ var iterEmpty = require( '@stdlib/iter/empty' );
2929
var iterMapN = 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

6534
tape( 'main export is a function', function test( t ) {
@@ -749,45 +718,6 @@ tape( 'the function returns an iterator protocol-compliant object which applies
749718
}
750719
});
751720

752-
tape( 'the function returns an iterator protocol-compliant object which applies a function to iterated values (value+done)', function test( t ) {
753-
var expected;
754-
var values1;
755-
var values2;
756-
var actual;
757-
var it;
758-
var i;
759-
760-
values1 = [ 1.0, 2.0 ];
761-
values2 = [ 3.0, 4.0 ];
762-
expected = [
763-
{
764-
'value': 4.0,
765-
'done': false
766-
},
767-
{
768-
'value': 6.0,
769-
'done': false
770-
},
771-
{
772-
'done': true
773-
}
774-
];
775-
776-
it = iterMapN( createIterator( values1 ), createIterator( values2 ), transform ); // eslint-disable-line max-len
777-
t.equal( it.next.length, 0, 'has zero arity' );
778-
779-
actual = [];
780-
for ( i = 0; i < expected.length; i++ ) {
781-
actual.push( it.next() );
782-
}
783-
t.deepEqual( actual, expected, 'returns expected values' );
784-
t.end();
785-
786-
function transform( x, y ) {
787-
return x + y;
788-
}
789-
});
790-
791721
tape( 'the function invokes a provided callback with iterated values and the iteration index', function test( t ) {
792722
var expected;
793723
var values1;
@@ -872,51 +802,6 @@ tape( 'the function supports specifying the callback execution context', functio
872802
}
873803
});
874804

875-
tape( 'the function supports specifying the callback execution context (value+done)', function test( t ) {
876-
var expected;
877-
var values1;
878-
var values2;
879-
var actual;
880-
var ctx;
881-
var it;
882-
var i;
883-
884-
ctx = {
885-
'count': 0
886-
};
887-
values1 = [ 1.0, 2.0 ];
888-
values2 = [ 3.0, 4.0 ];
889-
expected = [
890-
{
891-
'value': 4.0,
892-
'done': false
893-
},
894-
{
895-
'value': 6.0,
896-
'done': false
897-
},
898-
{
899-
'done': true
900-
}
901-
];
902-
903-
it = iterMapN( createIterator( values1 ), createIterator( values2 ), transform, ctx ); // eslint-disable-line max-len
904-
t.equal( it.next.length, 0, 'has zero arity' );
905-
906-
actual = [];
907-
for ( i = 0; i < expected.length; i++ ) {
908-
actual.push( it.next() );
909-
}
910-
t.deepEqual( actual, expected, 'returns expected values' );
911-
t.equal( ctx.count, expected.length-1 );
912-
t.end();
913-
914-
function transform( x, y ) {
915-
this.count += 1; // eslint-disable-line no-invalid-this
916-
return x + y;
917-
}
918-
});
919-
920805
tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) {
921806
var it;
922807
var r;

0 commit comments

Comments
 (0)