An open API service indexing awesome lists of open source software.

https://github.com/dighan/tickr

No dependencies, tiny and customizable JavaScript library to execute code repeatedly with fixed or dynamic delay.
https://github.com/dighan/tickr

delay setinterval timer

Last synced: 10 months ago
JSON representation

No dependencies, tiny and customizable JavaScript library to execute code repeatedly with fixed or dynamic delay.

Awesome Lists containing this project

README

          

# Tickr [![Build Status](https://travis-ci.org/dighan/tickr.svg?branch=master)](https://travis-ci.org/dighan/tickr)

No dependencies, tiny (`<2kB`) and customizable JavaScript library to execute code repeatedly with fixed or dynamic delay.

**Tickr** is subject to the [background browser mechanism](https://developers.google.com/web/updates/2017/03/background_tabs) and
cannot guarantee the `delay` is always honoured between ticks.

## Installation

Install the stable version with [`npm`](https://docs.npmjs.com/getting-started/what-is-npm):

```shell
npm install TBD --save-dev
```

or include it with a [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) tag:

```html
<script src="TBD" async>
```
## Usage

Intended to be bundled:

```js
import createTicker from 'Tickr'

const ticker = createTicker({ delay: 250 }, function() {
console.log(
ticker.getDelay(),
ticker.getImmediate(),
ticker.getMaxTicks()
)
}).start()
```

or in the browser:

```js
const ticker = Tickr.createTicker({ delay: 250 }, function() {
console.log(
ticker.getDelay(),
ticker.getImmediate(),
ticker.getMaxTicks()
)
}).start()
```

## License

MIT