# whiletrue

> Start/stop/pause/repeat: task runner in Javascript

Latest version **1.1.1** (published 2015-09-07) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2015-09-07 |
| First published | 2015-05-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | maurobussini |
| Maintainers | maurobussini |
| Keywords | linq, json, query, array |

## Links

- npm: https://www.npmjs.com/package/whiletrue
- npm.io page: https://npm.io/package/whiletrue

## Dependencies (1)

- [q](https://npm.io/package/q.md) ^1.4.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.1 (latest) — 2015-09-07
- 1.1.0 — 2015-07-30
- 1.0.2 — 2015-05-23

## README

whiletrue
======

Start/stop/pause/repeat: task runner in Javascript

## Usage

#### Given the following iteration condition...

```javascript
//Condition: iterate 10 times
function condition(state){

    //In 'state.index' is contained iteration 
    //number '0-based'
    return state.index < 10;
}
```

#### and the following task to run, over and over...

```javascript
//Task: do some work, then invoke "done"
function longTask(done, state){

    //Do some stuff here...
    console.log("Doing some stuff...");
    
    //Argument "state" => ex: { 
    //  iterations: 5,  //Current iteration number 
    //  delay: 10       //Delay (in ms) between iterations
    //}

    setTimeout(function(){

        //Task completed: remember to invoke ALWAYS "done"
        console.log("Task completed!");
        done();

    }, 1000);
}
```

#### just setup the "whiletrue" runner (with 10 millisecond of delay between each iteration)...

```javascript
//Setup: Create a "whiletrue" runner with 10 ms delay
var runner = whiletrue(condition, longTask, 10);
```

#### start the execution and handle the promise of "job completed"...

```javascript
//Start execution
runner.run()
    .then(function(){
        console.log("Job completed");
    });
```

#### ...or start the execution in parallel mode...

```javascript
//Start execution
runner.runParallel()
    .then(function(){
        console.log("Job completed");
    });
```

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