# chron

> Task scheduler

Latest version **0.1.1** (published 2018-01-17) · MIT license · 0 weekly downloads

## Install

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

## 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.1 |
| Published | 2018-01-17 |
| First published | 2015-06-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Diogo Resende |
| Maintainers | dresende |
| Keywords | cron, time, scheduler |

## Links

- npm: https://www.npmjs.com/package/chron
- Repository: https://github.com/dresende/chron
- Homepage: https://github.com/dresende/chron#readme
- Issues: https://github.com/dresende/chron/issues
- npm.io page: https://npm.io/package/chron

## Dependencies (1)

- [async](https://npm.io/package/async.md) 2.6.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.1 (latest) — 2018-01-17
- 0.1.0 — 2018-01-09
- 0.0.4 — 2015-06-22
- 0.0.3 — 2015-06-22
- 0.0.2 — 2015-06-22
- 0.0.1 — 2015-06-21

## README

# Chron

NodeJS task scheduler.

## Install

```sh
npm install chron
```

## Usage

```js
var chron = new require("chron")();

chron.add(10, doSomething); // called every 10 seconds
chron.add(1.5, doSomething); // called every 1.5 seconds

function doSomething() {
    console.log("doing..");
}
```

The advantage of the scheduler is it only has one timer, even if you have hundreds of tasks. It calculates when the next task needs to run and schedules a timer.

## API

- chron.add(period, task)
- chron.remove(task)
- chron.clear()
- chron.pause()
- chron.resume()

A `task` is a function that receives a parameter that you can use to control the task execution (the next calls).

```js
function doSomething($) {
    $.pause();   // will stop executing, you need to store
                 // a reference to $ to be able to resume
    $.resume();  // resume the previsouly paused task
    $.remove();  // completely remove the task - equal to chron.remove(task)
}
```

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