Skip to content

Commit 1d82d66

Browse files
committed
Refactor to ignore iterator return values
1 parent d4c8254 commit 1d82d66

File tree

2 files changed

+9
-79
lines changed

2 files changed

+9
-79
lines changed

lib/node_modules/@stdlib/simulate/iter/awun/lib/main.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,27 +246,26 @@ function iterawun( iterator, sigma, options ) {
246246
* @returns {Object} iterator protocol-compliant object
247247
*/
248248
function next() {
249-
var out;
250249
var v;
251250
if ( FLG ) {
252251
return {
253252
'done': true
254253
};
255254
}
256-
out = {};
257255
v = iterator.next();
258-
if ( typeof v.value === 'number' ) {
259-
out.value = v.value + runif();
260-
} else if ( hasOwnProp( v, 'value' ) ) {
261-
out.value = NaN;
262-
}
263256
if ( v.done ) {
264257
FLG = true;
265-
out.done = true;
258+
return v;
259+
}
260+
if ( typeof v.value === 'number' ) {
261+
v = v.value + runif();
266262
} else {
267-
out.done = false;
263+
v = NaN;
268264
}
269-
return out;
265+
return {
266+
'value': v,
267+
'done': false
268+
};
270269
}
271270

272271
/**

lib/node_modules/@stdlib/simulate/iter/awun/test/test.js

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -500,75 +500,6 @@ tape( 'the function supports providing a seeded pseudorandom number generator fo
500500
t.end();
501501
});
502502

503-
tape( 'the function returns an iterator protocol-compliant object which iteratively introduces additive white uniform noise (value+done)', function test( t ) {
504-
var expected;
505-
var actual;
506-
var values;
507-
var runif;
508-
var it;
509-
var v;
510-
var i;
511-
512-
runif = uniform.factory( -SQRT_THREE, SQRT_THREE, {
513-
'seed': 12345
514-
});
515-
516-
values = [ 2.0, 3.0, 2.0, 4.0, 3.0, 4.0 ];
517-
518-
expected = [];
519-
for ( i = 0; i < values.length; i++ ) {
520-
expected.push( values[i] + runif() );
521-
}
522-
523-
it = iterawun( createIterator( values ), 1.0, {
524-
'seed': 12345
525-
});
526-
t.equal( it.next.length, 0, 'has zero arity' );
527-
528-
actual = [];
529-
for ( i = 0; i < values.length; i++ ) {
530-
v = it.next();
531-
t.equal( typeof v.value, 'number', 'returns a number' );
532-
t.equal( typeof v.done, 'boolean', 'returns a boolean' );
533-
actual.push( v.value );
534-
}
535-
t.deepEqual( actual, expected, 'returns expected values' );
536-
537-
v = it.next();
538-
t.equal( v.value, void 0, 'returns expected value' );
539-
t.equal( v.done, true, 'returns expected value' );
540-
541-
t.end();
542-
543-
function createIterator( arr ) {
544-
var len;
545-
var it;
546-
var i;
547-
548-
len = arr.length;
549-
i = -1;
550-
551-
it = {};
552-
it.next = next;
553-
554-
return it;
555-
556-
function next() {
557-
var out;
558-
i += 1;
559-
if ( i < len ) {
560-
out = {};
561-
out.value = arr[ i ];
562-
out.done = ( i === len-1 );
563-
return out;
564-
}
565-
return {
566-
'done': true
567-
};
568-
}
569-
}
570-
});
571-
572503
tape( 'if an iterated value is a non-numeric value, the returned value is `NaN`', function test( t ) {
573504
var values;
574505
var it;

0 commit comments

Comments
 (0)