# loop-events

> multiple event for eventemit

Latest version **0.2.3** (published 2016-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install loop-events
pnpm add loop-events
yarn add loop-events
bun add loop-events
```

## 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.2.3 |
| Published | 2016-02-05 |
| First published | 2016-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | shaoyihe |
| Maintainers | shaoyihe |
| Keywords | loop-events, LoopEvents, multiple event, EventEmit |

## Links

- npm: https://www.npmjs.com/package/loop-events
- Repository: https://github.com/shaoyihe/LoopEvents
- Homepage: https://github.com/shaoyihe/LoopEvents#readme
- Issues: https://github.com/shaoyihe/LoopEvents/issues
- npm.io page: https://npm.io/package/loop-events

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 0.2.3 (latest) — 2016-02-05
- 0.2.2 — 2016-02-05
- 0.2.1 — 2016-02-05
- 0.2.0 — 2016-02-05
- 0.1.0 — 2016-02-05

## README

# Loop EventEmit

multiple asynchronous event for eventemit

## Installation

     npm install loop-events
      
## Usage
      
multiple asynchronous event complete :

    var LoopEvent = require("loop-events"),
        https = require("https");
    
    var urlEvent = new LoopEvent();
    var urls = ["https://github.com/", "https://github.com/", "https://github.com/"];
    
    urlEvent.setChildCount(urls.length);
    urlEvent.on("allDone", function () {
        console.log("allDone");
    });
    urls.forEach(function (url) {
        https.request(url, function () {
            urlEvent.emit("childDone");
        }).end();
    });
    
 
more complex (recursion folder complete event):

    var LoopEvent = require("loop-events"),
        fs = require("fs"),
        path = require("path");
    
    var root = path.resolve(__dirname, "..");
    var event = new LoopEvent();
    function loopdir(folder, parent) {
        fs.readdir(folder, function (err, files) {
            if (files.length == 0) {
                parent.emit("childAllDone")
                return;
            }
            parent.setChildCount(files.length);
            files.forEach(function (file) {
                var curLoopEvents = new LoopEvent(parent);
                var absPath = path.join(folder, file);
                fs.stat(absPath, function (err, stas) {
                    if (stas.isDirectory()) {
                        loopdir(absPath, curLoopEvents);
                    } else {
                        curLoopEvents.emit("childAllDone", absPath);
                    }
                })
            })
        })
    }

    event.on("allDone", function () {
        console.log("allDone");
    });
    loopdir(root, event);

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