Skip to content

Commit e75cfe5

Browse files
committed
Refactor to ignore iterator return values
1 parent d4fcb53 commit e75cfe5

File tree

2 files changed

+1
-85
lines changed

2 files changed

+1
-85
lines changed

lib/node_modules/@stdlib/iter/for-each/lib/main.js

Lines changed: 1 addition & 10 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

@@ -92,7 +91,6 @@ function iterForEach( iterator, fcn, thisArg ) {
9291
* @returns {Object} iterator protocol-compliant object
9392
*/
9493
function next() {
95-
var out;
9694
var v;
9795
i += 1;
9896
if ( FLG ) {
@@ -103,14 +101,7 @@ function iterForEach( iterator, fcn, thisArg ) {
103101
v = iterator.next();
104102
if ( v.done ) {
105103
FLG = true;
106-
out = {};
107-
if ( hasOwnProp( v, 'value' ) ) {
108-
v = v.value;
109-
fcn.call( thisArg, v, i );
110-
out.value = v;
111-
}
112-
out.done = true;
113-
return out;
104+
return v;
114105
}
115106
v = v.value;
116107
fcn.call( thisArg, v, i );

lib/node_modules/@stdlib/iter/for-each/test/test.js

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -119,81 +119,6 @@ tape( 'the function returns an iterator protocol-compliant object', function tes
119119
}
120120
});
121121

122-
tape( 'the function returns an iterator protocol-compliant object (value+done)', function test( t ) {
123-
var expected;
124-
var actual;
125-
var values;
126-
var count;
127-
var it;
128-
var i;
129-
130-
values = [ 1, 2, 3, 4 ];
131-
expected = [
132-
{
133-
'value': 1,
134-
'done': false
135-
},
136-
{
137-
'value': 2,
138-
'done': false
139-
},
140-
{
141-
'value': 3,
142-
'done': false
143-
},
144-
{
145-
'value': 4,
146-
'done': true
147-
}
148-
];
149-
150-
it = iterForEach( createIterator( values ), assert );
151-
t.equal( it.next.length, 0, 'has zero arity' );
152-
153-
actual = [];
154-
count = 0;
155-
for ( i = 0; i < values.length; i++ ) {
156-
actual.push( it.next() );
157-
}
158-
t.deepEqual( actual, expected, 'returns expected values' );
159-
t.equal( count, values.length, 'returns expected value' );
160-
t.end();
161-
162-
function assert( v, i ) {
163-
count += 1;
164-
t.equal( isnan( v ), false, 'is not NaN' );
165-
t.equal( isnan( i ), false, 'is not NaN' );
166-
}
167-
168-
function createIterator( arr ) {
169-
var len;
170-
var it;
171-
var i;
172-
173-
len = arr.length;
174-
i = -1;
175-
176-
it = {};
177-
it.next = next;
178-
179-
return it;
180-
181-
function next() {
182-
var out;
183-
i += 1;
184-
if ( i < len ) {
185-
out = {};
186-
out.value = arr[ i ];
187-
out.done = ( i === len-1 );
188-
return out;
189-
}
190-
return {
191-
'done': true
192-
};
193-
}
194-
}
195-
});
196-
197122
tape( 'the function returns an iterator protocol-compliant object which invokes a provided function for each iterated value before returning the iterated value', function test( t ) {
198123
var expected;
199124
var opts;

0 commit comments

Comments
 (0)