extra-iterable
Advanced tools
Comparing version 3.0.108 to 3.0.109
@@ -1137,2 +1137,20 @@ /** | ||
/** | ||
* Place a separator between every value. | ||
* [📘](https://github.com/nodef/extra-iterable/wiki/intersperse) | ||
* @param x an iterable | ||
* @param v separator | ||
* @returns x[0], v, x[1], v, ..., x[|x|-1] | ||
* */ | ||
declare function intersperse<T>(x: Iterable<T>, v: T): IterableIterator<T>; | ||
/** | ||
* Estimate new values between existing ones. | ||
* [📘](https://github.com/nodef/extra-iterable/wiki/interpolate) | ||
* @param x an iterable | ||
* @param fc combine function (a, b) | ||
* @returns x[0], fc(x[0], x[1]), x[1], fc(x[1], x[2]), ..., x[|x|-1] | ||
* */ | ||
declare function interpolate<T>(x: Iterable<T>, fc: CombineFunction<T>): IterableIterator<T>; | ||
/** | ||
* Place values of an iterable between another. | ||
@@ -1159,20 +1177,2 @@ * [📘](https://github.com/nodef/extra-iterable/wiki/intermix) | ||
/** | ||
* Estimate new values between existing ones. | ||
* [📘](https://github.com/nodef/extra-iterable/wiki/interpolate) | ||
* @param x an iterable | ||
* @param fc combine function (a, b) | ||
* @returns x[0], fc(x[0], x[1]), x[1], fc(x[1], x[2]), ..., x[|x|-1] | ||
* */ | ||
declare function interpolate<T>(x: Iterable<T>, fc: CombineFunction<T>): IterableIterator<T>; | ||
/** | ||
* Place a separator between every value. | ||
* [📘](https://github.com/nodef/extra-iterable/wiki/intersperse) | ||
* @param x an iterable | ||
* @param v separator | ||
* @returns x[0], v, x[1], v, ..., x[|x|-1] | ||
* */ | ||
declare function intersperse<T>(x: Iterable<T>, v: T): IterableIterator<T>; | ||
/** | ||
* Append values from iterables. | ||
@@ -1179,0 +1179,0 @@ * [📘](https://github.com/nodef/extra-iterable/wiki/concat) |
32
index.js
@@ -992,2 +992,18 @@ 'use strict'; | ||
} | ||
function* intersperse(x, v) { | ||
var i = -1; | ||
for (var u of x) { | ||
if (++i > 0) | ||
yield v; | ||
yield u; | ||
} | ||
} | ||
function* interpolate(x, fc) { | ||
var u, i = -1; | ||
for (var v of x) { | ||
if (++i > 0) | ||
yield fc(u, v); | ||
yield (u = v); | ||
} | ||
} | ||
function* intermix(x, y, m = 1, n = 1, s = m, t = n) { | ||
@@ -1024,18 +1040,2 @@ var x1 = chunk(x, m, s); | ||
} | ||
function* interpolate(x, fc) { | ||
var u, i = -1; | ||
for (var v of x) { | ||
if (++i > 0) | ||
yield fc(u, v); | ||
yield (u = v); | ||
} | ||
} | ||
function* intersperse(x, v) { | ||
var i = -1; | ||
for (var u of x) { | ||
if (++i > 0) | ||
yield v; | ||
yield u; | ||
} | ||
} | ||
function* concat(...xs) { | ||
@@ -1042,0 +1042,0 @@ for (var x of xs) |
{ | ||
"name": "extra-iterable", | ||
"version": "3.0.108", | ||
"version": "3.0.109", | ||
"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