extra-iterable
Advanced tools
Comparing version 3.0.111 to 3.0.112
@@ -1168,6 +1168,6 @@ /** | ||
/** | ||
* Merge values from iterables. | ||
* Place values from iterables alternately. | ||
* [📘](https://github.com/nodef/extra-iterable/wiki/interleave) | ||
* @param xs iterables | ||
* @returns TODO | ||
* @returns x₀[0], x₁[0], ..., x₀[1], x₁[0], ... | [x₀, x₁, ...] = xs | ||
* */ | ||
@@ -1174,0 +1174,0 @@ |
29
index.js
@@ -586,3 +586,3 @@ 'use strict'; | ||
return false; | ||
for (var i = 0, j = n - Y; i < Y; i++, j++) { | ||
for (var i = 0, j = n - Y; i < Y; ++i, ++j) { | ||
var u1 = fm(a[ai++ % Y], j, x); | ||
@@ -1020,20 +1020,15 @@ var v1 = fm(y1[i], i, y); | ||
function* interleave(xs) { | ||
var X = xs.length; | ||
var ix = [], ax = []; | ||
for (var n = 0, i = 0; n < X; n++) { | ||
var X = xs.length, ix = []; | ||
for (var i = 0; i < X; ++i) | ||
ix[i] = xs[i][Symbol.iterator](); | ||
ax[i] = ix[i].next(); | ||
if (!ax[i].done) | ||
i++; | ||
} | ||
for (var j = 0; i > 0; j++) { | ||
var vs = ax.map(o => o.value); | ||
j %= i; | ||
yield vs[j]; | ||
ax[j] = ix[j].next(); | ||
if (!ax[j].done) | ||
for (var i = 0, n = X; n > 0; i = (i + 1) % X) { | ||
if (ix[i] == null) | ||
continue; | ||
ix.splice(j, 1); | ||
ax.splice(j, 1); | ||
i--; | ||
var a = ix[i].next(); | ||
if (a.done) { | ||
ix[i] = null; | ||
--n; | ||
} | ||
else | ||
yield a.value; | ||
} | ||
@@ -1040,0 +1035,0 @@ } |
{ | ||
"name": "extra-iterable", | ||
"version": "3.0.111", | ||
"version": "3.0.112", | ||
"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
1
123900
3824