Skip to content

Commit 616dc89

Browse files
committed
Auto-generated commit
1 parent 26f58f1 commit 616dc89

File tree

4 files changed

+6
-156
lines changed

4 files changed

+6
-156
lines changed

.github/workflows/test_coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ jobs:
7272
env:
7373
webhook_url: ${{ secrets.STDLIB_COVERAGE_URL }}
7474
webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }}
75-
data: '{ "coverage": ${{ steps.extract-coverage.outputs.coverage }}, "run_id": "${{ github.run_id }}" }'
75+
data: '${{ steps.extract-coverage.outputs.coverage }}'
7676
if: ${{ false }}

lib/main.js

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-propert
2424
var isFunction = require( '@stdlib/assert-is-function' );
2525
var isIteratorLike = require( '@stdlib/assert-is-iterator-like' );
2626
var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;
27-
var hasOwnProp = require( '@stdlib/assert-has-own-property' );
2827
var iteratorSymbol = require( '@stdlib/symbol-iterator' );
2928

3029

@@ -90,40 +89,21 @@ function iterReplicate( iterator, n ) {
9089
* @returns {Object} iterator protocol-compliant object
9190
*/
9291
function next() {
93-
var out;
9492
var v;
95-
if ( FLG === 2 ) {
93+
if ( FLG ) {
9694
return {
9795
'done': true
9896
};
9997
}
10098
i += 1;
10199
if ( i === n ) {
102-
if ( FLG === 1 ) {
103-
// If we are here, we have finished the last of the replicates...
104-
FLG = 2;
105-
return {
106-
'done': true
107-
};
108-
}
109100
v = iterator.next();
110101
if ( v.done ) {
111-
out = {};
112-
if ( hasOwnProp( v, 'value' ) ) {
113-
// We still need to replicate one more value...
114-
value = v.value; // cached value
115-
out.value = value;
116-
out.done = false;
117-
FLG = 1;
118-
i = 0; // reset the counter
119-
} else {
120-
out.done = true;
121-
FLG = 2;
122-
}
123-
return out;
102+
FLG = true;
103+
return v;
124104
}
125105
i = 0; // reset the counter
126-
value = v.value; // cached value
106+
value = v.value; // cache value
127107
}
128108
return {
129109
'value': value,
@@ -139,7 +119,7 @@ function iterReplicate( iterator, n ) {
139119
* @returns {Object} iterator protocol-compliant object
140120
*/
141121
function end( value ) {
142-
FLG = 2;
122+
FLG = true;
143123
if ( arguments.length ) {
144124
return {
145125
'value': value,

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"url": "https://github.com/stdlib-js/stdlib/issues"
3838
},
3939
"dependencies": {
40-
"@stdlib/assert-has-own-property": "^0.0.x",
4140
"@stdlib/assert-is-function": "^0.0.x",
4241
"@stdlib/assert-is-iterator-like": "^0.0.x",
4342
"@stdlib/assert-is-positive-integer": "^0.0.x",

test/test.js

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,6 @@ var iteratorSymbol = require( '@stdlib/symbol-iterator' );
2828
var iterReplicate = require( './../lib' );
2929

3030

31-
// FUNCTIONS //
32-
33-
function createIterator( arr ) {
34-
var len;
35-
var it;
36-
var i;
37-
38-
len = arr.length;
39-
i = -1;
40-
41-
it = {};
42-
it.next = next;
43-
44-
return it;
45-
46-
function next() {
47-
var out;
48-
i += 1;
49-
if ( i < len ) {
50-
out = {};
51-
out.value = arr[ i ];
52-
out.done = ( i === len-1 );
53-
return out;
54-
}
55-
return {
56-
'done': true
57-
};
58-
}
59-
}
60-
61-
6231
// TESTS //
6332

6433
tape( 'main export is a function', function test( t ) {
@@ -264,104 +233,6 @@ tape( 'the function returns an iterator protocol-compliant object which replicat
264233
t.end();
265234
});
266235

267-
tape( 'the function returns an iterator protocol-compliant object which replicates each iterated value a specified number of times (value+done; >1)', function test( t ) {
268-
var expected;
269-
var values;
270-
var actual;
271-
var it;
272-
var i;
273-
274-
values = [ 1, 2, 3, 4 ];
275-
expected = [
276-
{
277-
'value': 1,
278-
'done': false
279-
},
280-
{
281-
'value': 1,
282-
'done': false
283-
},
284-
{
285-
'value': 2,
286-
'done': false
287-
},
288-
{
289-
'value': 2,
290-
'done': false
291-
},
292-
{
293-
'value': 3,
294-
'done': false
295-
},
296-
{
297-
'value': 3,
298-
'done': false
299-
},
300-
{
301-
'value': 4,
302-
'done': false
303-
},
304-
{
305-
'value': 4,
306-
'done': false
307-
},
308-
{
309-
'done': true
310-
}
311-
];
312-
313-
it = iterReplicate( createIterator( values ), 2 );
314-
t.equal( it.next.length, 0, 'has zero arity' );
315-
316-
actual = [];
317-
for ( i = 0; i < expected.length; i++ ) {
318-
actual.push( it.next() );
319-
}
320-
t.deepEqual( actual, expected, 'returns expected values' );
321-
t.end();
322-
});
323-
324-
tape( 'the function returns an iterator protocol-compliant object which replicates each iterated value a specified number of times (value+done; once)', function test( t ) {
325-
var expected;
326-
var values;
327-
var actual;
328-
var it;
329-
var i;
330-
331-
values = [ 1, 2, 3, 4 ];
332-
expected = [
333-
{
334-
'value': 1,
335-
'done': false
336-
},
337-
{
338-
'value': 2,
339-
'done': false
340-
},
341-
{
342-
'value': 3,
343-
'done': false
344-
},
345-
{
346-
'value': 4,
347-
'done': false
348-
},
349-
{
350-
'done': true
351-
}
352-
];
353-
354-
it = iterReplicate( createIterator( values ), 1 );
355-
t.equal( it.next.length, 0, 'has zero arity' );
356-
357-
actual = [];
358-
for ( i = 0; i < expected.length; i++ ) {
359-
actual.push( it.next() );
360-
}
361-
t.deepEqual( actual, expected, 'returns expected values' );
362-
t.end();
363-
});
364-
365236
tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) {
366237
var it;
367238
var r;

0 commit comments

Comments
 (0)