# phuture

> future utility cancel manipulate timer function

Latest version **1.0.7** (published 2017-10-26) · ISC license · 0 weekly downloads

## Install

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

## 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.0.7 |
| Published | 2017-10-26 |
| First published | 2014-11-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | mhzed |
| Maintainers | mhzed |
| Keywords | future, cancel, timer, function |

## Links

- npm: https://www.npmjs.com/package/phuture
- Repository: https://github.com/mhzed/phuture
- Homepage: https://github.com/mhzd/phuture
- Issues: https://github.com/mhzd/phuture/issues
- npm.io page: https://npm.io/package/phuture

## Recent versions

- 1.0.7 (latest) — 2017-10-26
- 1.0.6 — 2017-04-20
- 1.0.5 — 2017-02-17
- 1.0.4 — 2017-02-17
- 1.0.2 — 2014-11-05
- 1.0.1 — 2014-11-04
- 1.0.0 — 2014-11-04

## README

phuture
--------

A future utility to manipulate javascript timers, because:

- setTimeout and setInterval has callBack as the first parameter, painful to work with
- makes it easier to cancel timer
- makes it easier to readjust timer
- wrap any async function with timeout 
- easy loop

## Installation

    npm install phuture

## Examples
    
    var future = require("phuture")
    
    var onceTask = future.once( 1000, runCb)  // 1 sec in the future
    
    onceTask.cancel();  // cancel timer, will not ever run
    onceTask.finish();  // if not yet run, run immediately then cancel timer, if already run, no affect
    onceTask.result();  // whatever runCb() returned
     
    var manyTask = future.interval( msInterval, runCb)
    
    manyTask.cancel();  // cancel timer, will not ever run
    manyTask.finishAfter(n);  // run n more times, then stop timer
    manyTask.result();        // whatever most recent runCb() returned
    manyTask.resetInterval(msInterval/2)  // run twice faster!
    
    // async loop twice, delay 1s in between
    future.loop(1000, (i, next)=>{
      if (i<2) next();
    })
    
    
See test/test.coffee for more examples.

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