extra-iterable
Advanced tools
Comparing version 3.0.117 to 3.0.118
@@ -1104,5 +1104,5 @@ /** | ||
* @param x an iterable | ||
* @param i start index (0) | ||
* @param n number of values (-1 ⇒ Inf) | ||
* @returns TODO | ||
* @param i start index [0] | ||
* @param n number of values [-1 ⇒ Inf] | ||
* @returns x[i..] ⧺ x ⧺ x ⧺ ... with upto n values | ||
* */ | ||
@@ -1109,0 +1109,0 @@ |
24
index.js
@@ -940,6 +940,13 @@ 'use strict'; | ||
function* cycle(x, i = 0, n = -1) { | ||
var x = toMany(x); | ||
var i = i === 0 ? 0 : mod(i, length(x)); | ||
var x = toMany(x), X = 0; | ||
if (i < 0) { | ||
X = length(x); | ||
if (X === 0) | ||
return; | ||
i = mod(i, X); | ||
} | ||
while (true) { | ||
X = 0; | ||
for (var v of x) { | ||
++X; | ||
if (--i >= 0) | ||
@@ -951,2 +958,6 @@ continue; | ||
} | ||
if (X === 0) | ||
return; | ||
if (i >= X) | ||
i = mod(i, X); | ||
} | ||
@@ -980,3 +991,3 @@ } | ||
} | ||
if (++i >= n) { | ||
if (++i === 0 || i >= n) { | ||
yield* a; | ||
@@ -991,2 +1002,4 @@ return; | ||
var a = Array.from(x); | ||
if (a.length === 0) | ||
return; | ||
var n = n % a.length; | ||
@@ -1023,3 +1036,6 @@ yield* a.slice(-n); | ||
function* interleave(xs) { | ||
var X = xs.length, ix = []; | ||
var X = xs.length; | ||
if (X === 0) | ||
return; | ||
var ix = []; | ||
for (var i = 0; i < X; ++i) | ||
@@ -1026,0 +1042,0 @@ ix[i] = xs[i][Symbol.iterator](); |
{ | ||
"name": "extra-iterable", | ||
"version": "3.0.117", | ||
"version": "3.0.118", | ||
"description": "An iterable is a sequence of values.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124570
3856