# advanced-timeout

> An advanced, pausable, timeout module for javascript

Latest version **1.1.0** (published 2019-06-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install advanced-timeout
pnpm add advanced-timeout
yarn add advanced-timeout
bun add advanced-timeout
```

## 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.0 |
| Published | 2019-06-05 |
| First published | 2019-06-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Eden Ben Shoshan |
| Maintainers | edenbs |
| Keywords | timeout, pause, settimeout, pausable timeout, pause timeout, stop timeout, advanced |

## Links

- npm: https://www.npmjs.com/package/advanced-timeout
- Repository: https://github.com/edenbs/advanced-timeout
- Homepage: https://github.com/edenbs/advanced-timeout#readme
- Issues: https://github.com/edenbs/advanced-timeout/issues
- npm.io page: https://npm.io/package/advanced-timeout

## Dependencies (1)

- [uuid](https://npm.io/package/uuid.md) ^3.3.2

## Recent versions

- 1.1.0 (latest) — 2019-06-05
- 1.0.2 — 2019-06-03
- 1.0.1 — 2019-06-02
- 1.0.0 — 2019-06-02

## README

# advanced-timeout
An advanced, pausable, timeout module for javascript

## API

### set
Activate timeout the same way you'd use javascript's setTimeout()
Use the returned timeoutID in order to invoke other functions on your timeout such as pause etc
    
    const timeout = require('advanced-timeout');

    const timeoutID = timeout.set(() => {
            console.log('Hello World');
    }, 1000);

### pause
Pause timeout.
Returns a boolean indicating whether paused successfully or not.
    
    timeout.pause(timeoutID);

### resume
Resume a paused timeout.
Returns a boolean indicating whether resumed successfully or not.
    
    timeout.resume(timeoutID);

### getRemainingTime
Returns the time left (in milliseconds) for timeout until its function is invoked.
    
    console.log('Remaining time for timeout:', timeout.getRemainingTime(timeoutID));

### clear
Clears timeout the same way javascript's clearTimeout() does.
    
    timeout.clear(timeoutID);

## Example
    const timeout = require('advanced-timeout');

    // Print 'Hello World' in a second
    const timeoutID = timeout.set(() => {
        console.log('Hello World');
    }, 1000);

    // In 300 ms pause timeout and print remaining time
    timeout.set(() => {
        timeout.pause(timeoutID);

        console.log('Remaining time for timeout:', timeout.getRemainingTime(timeoutID)); 
        // Remaining time for timeout: (Something around 700)

        // Resume timeout in a second
        timeout.set(() => {
            timeout.resume(timeoutID);
        }, 1000)
    }, 300);

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