# timers-ext

> Timers extensions

Latest version **0.1.8** (published 2024-06-03) · ISC license · 0 weekly downloads

## Install

```sh
npm install timers-ext
pnpm add timers-ext
yarn add timers-ext
bun add timers-ext
```

## 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.1.8 |
| Published | 2024-06-03 |
| First published | 2013-08-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.12 |
| Dependencies | 2 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Mariusz Nowak |
| Maintainers | medikoo |
| Keywords | timeout, delay, interval, time, timer, timers |

## Links

- npm: https://www.npmjs.com/package/timers-ext
- Repository: https://github.com/medikoo/timers-ext
- Homepage: https://github.com/medikoo/timers-ext#readme
- Issues: https://github.com/medikoo/timers-ext/issues
- npm.io page: https://npm.io/package/timers-ext

## Dependencies (2)

- [es5-ext](https://npm.io/package/es5-ext.md) ^0.10.64
- [next-tick](https://npm.io/package/next-tick.md) ^1.1.0

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 0.1.8 (latest) — 2024-06-03
- 0.1.7 — 2018-10-04
- 0.1.6 — 2018-10-04
- 0.1.5 — 2018-03-13
- 0.1.4 — 2018-03-08
- 0.1.3 — 2018-03-07
- 0.1.2 — 2017-04-03
- 0.1.1 — 2017-03-15
- 0.1.0 — 2014-04-27
- 0.0.0 — 2013-08-27

## README

[![Build status][build-image]][build-url]
[![Tests coverage][cov-image]][cov-url]
[![npm version][npm-image]][npm-url]

# timers-ext

## Timers extensions

### Installation

    $ npm install timers-ext

To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/)

### API

#### MAX*TIMEOUT *(timers-ext/max-timeout)\_

Maximum possible timeout value in milliseconds. It equals to maximum positive value for 32bit signed integer, so _2³¹ (2147483647)_, which makes it around 24.9 days

#### delay(fn[, timeout]) _(timers-ext/delay)_

Returns function which when invoked will call _fn_ function after specified
_timeout_. If _timeout_ is not provided [nextTick](https://github.com/medikoo/next-tick/#next-tick) propagation is used.

#### once(fn[, timeout]) _(timers-ext/once)_

Makes sure to execute _fn_ function only once after a defined interval of time (debounce). If _timeout_ is not provided [nextTick](https://github.com/medikoo/next-tick/#next-tick) propagation is used.

```javascript
var nextTick = require("next-tick");
var logFoo = function () { console.log("foo"); };
var logFooOnce = require("timers-ext/once")(logFoo);

logFooOnce();
logFooOnce(); // ignored, logFoo will be logged only once
logFooOnce(); // ignored

nextTick(function () {
  logFooOnce(); // Invokes another log (as tick passed)
  logFooOnce(); // ignored
  logFooOnce(); // ignored
});
```

#### validTimeout(timeout) _(timers-ext/valid-timeout)_

Validates timeout value.  
For `NaN` resolved _timeout_ `0` is returned.
If _timeout_ resolves to a number:

- for _timeout < 0_ `0` is returned
- for _0 >= timeout <= [MAX_TIMEOUT](#max_timeout-timers-extmax-timeout)_, `timeout` value is returned
- for _timeout > [MAX_TIMEOUT](#max_timeout-timers-extmax-timeout)_ exception is thrown

### Tests

    $ npm test

## Security contact information

To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.

[build-image]: https://github.com/medikoo/timers-ext/workflows/Integrate/badge.svg
[build-url]: https://github.com/medikoo/timers-ext/actions?query=workflow%3AIntegrate
[cov-image]: https://img.shields.io/codecov/c/github/medikoo/timers-ext.svg
[cov-url]: https://codecov.io/gh/medikoo/timers-ext
[npm-image]: https://img.shields.io/npm/v/timers-ext.svg
[npm-url]: https://www.npmjs.com/package/timers-ext

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