extra-iterable
Advanced tools
Comparing version 3.2.15 to 3.2.16
{ | ||
"name": "extra-iterable", | ||
"version": "3.2.15", | ||
"description": "A collection of functions for operating upon iterables.", | ||
"version": "3.2.16", | ||
"description": "An iterable is a sequence of values.", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "module": "index.mjs", |
@@ -1,2 +0,2 @@ | ||
A collection of functions for operating upon iterables.<br> | ||
An [iterable] is a sequence of values.<br> | ||
📦 [Node.js](https://www.npmjs.com/package/extra-iterable), | ||
@@ -8,9 +8,9 @@ 🌐 [Web](https://www.npmjs.com/package/extra-iterable.web), | ||
An [iterable] is a sequence of values. Assumption here is that an iterable can | ||
only be iterated over once. Methods which require multiple iterations preserve | ||
old values in a backup array using [toMany]. Many methods accept both compare | ||
and map functions, and in some cases using **only** a map function enables | ||
*faster comparision* (like [unique]). I borrowed a lot of ideas from Haskell, | ||
Elm, Python, Basic, Lodash, and other NPM packages. These are mentioned in | ||
references of each method. | ||
This is a collection of functions for operating upon **iterables**. Assumption | ||
here is that an **iterable** can *only* be iterated over *once*. Methods which | ||
require multiple iterations preserve old values in a backup array using | ||
[toMany]. Many methods accept both compare and map functions, and in some cases | ||
using **only** a map function enables *faster comparision* (like [unique]). I | ||
borrowed a lot of ideas from Haskell, Elm, Python, Basic, Lodash, and other NPM | ||
packages. These are mentioned in references of each method. | ||
@@ -29,20 +29,20 @@ This package is available in *Node.js* and *Web* formats. The web format | ||
```javascript | ||
const iterable = require('extra-iterable'); | ||
// import * as iterable from "extra-iterable"; | ||
// import * as iterable from "https://unpkg.com/extra-iterable/index.mjs"; (deno) | ||
const xiterable = require('extra-iterable'); | ||
// import * as xiterable from "extra-iterable"; | ||
// import * as xiterable from "https://unpkg.com/extra-iterable/index.mjs"; (deno) | ||
var x = [2, 4, 6, 8]; | ||
iterable.get(x, 1); | ||
xiterable.get(x, 1); | ||
// → 4 | ||
var x = [1, 2, 3, 4]; | ||
[...iterable.swap(x, 0, 1)]; | ||
[...xiterable.swap(x, 0, 1)]; | ||
// → [ 2, 1, 3, 4 ] | ||
var x = [1, 2, 3]; | ||
[...iterable.cycle(x, 0, 4)]; | ||
[...xiterable.cycle(x, 0, 4)]; | ||
// → [1, 2, 3, 1] | ||
var x = [1, 2, 3, 4]; | ||
iterable.reduce(x, (acc, v) => acc+v); | ||
xiterable.reduce(x, (acc, v) => acc+v); | ||
// → 10 | ||
@@ -49,0 +49,0 @@ ``` |
130367