# aiter

> Lightweight async iterator for Node.js

Latest version **0.0.13** (published 2016-03-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install aiter
pnpm add aiter
yarn add aiter
bun add aiter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.13 |
| Published | 2016-03-18 |
| First published | 2015-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jinsung Oh |
| Maintainers | econquer |
| Keywords | async, range, loop, for, forEach, each, count, map, promise, iter, iterator, fast, lightweight, utility, easy, async for, async forEach, async loop, async range, async count |

## Links

- npm: https://www.npmjs.com/package/aiter
- Repository: https://github.com/econquer/aiter-js
- Homepage: https://github.com/econquer/aiter-js#readme
- Issues: https://github.com/econquer/aiter-js/issues
- npm.io page: https://npm.io/package/aiter

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.13 (latest) — 2016-03-18
- 0.0.12 — 2016-03-17
- 0.0.11 — 2016-03-16
- 0.0.9 — 2015-07-29
- 0.0.8 — 2015-07-23
- 0.0.7 — 2015-07-23
- 0.0.6 — 2015-07-22
- 0.0.5 — 2015-07-22

## README

# aiter-js

Lightweight async iterator for Node.js


### Quick Examples
```js
var range = require('aiter').range;
range(1, 10).forEach(function (i, next) {
    setTimeout(function() {
	    console.log('visit ' + i);
	    next();
    });
}).then(function () {
    console.log('async iteration complete');
});
```

## Installation

```bash
$ npm install aiter
```

## Examples
#### async array iteration
```js
var range = require('aiter').range;
range(['a', 'b', 'c', 'd']).forEach(function (i, next) {
    setTimeout(function() {
	    console.log('visit ' + i);
	    next();
    });
}).then(function () {
    console.log('async iteration complete');
});

var aiter = require('aiter');
aiter.forEach(['a', 'b', 'c', 'd'], function (i, next) {
    setTimeout(function() {
	    console.log('visit ' + i);
	    next();
    });
}).then(function () {
    console.log('async iteration complete');
});
```

#### async numeric loop
```js
var range = require('aiter').range;
range(1,100).forEach(function (i, next) {
    setTimeout(function() {
	    console.log('visit ' + i);
	    next();
    });
}).then(function () {
    console.log('async iteration complete');
});

var aiter = require('aiter');
aiter.forEach(aiter.range(1,100), function (i, next) {
    setTimeout(function() {
	    console.log('visit ' + i);
	    next();
    });
}).then(function () {
    console.log('async iteration complete');
});
```

#### omitted next function
```js
var range = require('aiter').range;
range(1,100).forEach(function (i) {
    console.log('visit ' + i);
}).then(function () {
    console.log('async iteration complete');
});

var aiter = require('aiter');
aiter.forEach(aiter.range(1,100), function (i) {
    console.log('visit ' + i);
}).then(function () {
    console.log('async iteration complete');
});
```
#### skip iteration
```js
var range = require('aiter').range;
range(1,10).forEach(function (i, next, iter) {
    console.log('visit ' + i);
    if(i == 3) {
        var skipped = iter.skip(3); // skipped is [4, 5, 6]
        console.log("skipped: " + skipped);
    }
    next();
}).then(function () {
    console.log('async iteration complete');
});
```

#### simple count
```js
var range = require('aiter').range;
range(1, 10).count(function condition(i) { return i % 2 == 0; }, function result(count) {
  console.log('range(1, 10).count(i %% 2) => %d', count);
});
```

#### async count
```js
var range = require('aiter').range;
range(1, 10000).count(function asyncCondition(i, next) {
  process.nextTick(function(){
    next(i % 2 == 0);
  });
}, function result(count) {
  console.log('range(1, 10000).count(i %% 2) => %d', count);
});
```

## License

  [MIT](LICENSE)

---
_Source: https://npm.io/package/aiter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
