UNPKG

axax

Version:

A library of async iterator extensions for JavaScript including ```map```, ```reduce```, ```filter```, ```flatMap```, ```pipe``` and [more](https://github.com/jamiemccrindle/axax/blob/master/docs/API.md#functions).

26 lines (25 loc) 751 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Creates an iterable of numbers (positive and/or negative) * progressing from start up to, but not including, end. A step * of -1 is used if a negative start is specified without an end * or step. If end is not specified, it's set to start with start * then set to 0. */ async function* range(startOrEnd, end, step = 1) { let actualStart; let actualEnd; if (end === undefined) { actualStart = 0; actualEnd = startOrEnd; } else { actualStart = startOrEnd; actualEnd = end; } for (let i = actualStart; step > 0 ? i < actualEnd : i > actualEnd; i += step) { yield i; } } exports.range = range;