# abm-cron

> A compact library that parses cron-like expressions and finds its nearest time of run.

Latest version **1.2.0** (published 2019-05-02) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install abm-cron
pnpm add abm-cron
yarn add abm-cron
bun add abm-cron
```

## 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.2.0 |
| Published | 2019-05-02 |
| First published | 2019-05-01 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 23.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alexander Berezin |
| Maintainers | lmcx |
| Keywords | cron, crontab, parser, parsing |

## Links

- npm: https://www.npmjs.com/package/abm-cron
- Repository: https://github.com/lmcsu/abm-cron
- Homepage: https://github.com/lmcsu/abm-cron#readme
- Issues: https://github.com/lmcsu/abm-cron/issues
- npm.io page: https://npm.io/package/abm-cron

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2019-05-02
- 1.1.0 — 2019-05-01

## README

# abm-cron

![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/lmcsu/abm-cron.svg)
![npm bundle size](https://img.shields.io/bundlephobia/min/abm-cron.svg)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/abm-cron.svg)

A compact library that parses cron-like expressions and finds its nearest time of run.
Without any external dependencies.

## Install

#### Node.js
```bash
$ npm install abm-cron
```
```js
const abmCron = require('abm-cron');
````
#### Browser
```html
<script src="<your_path>/abm-cron.min.js"></script>
```

## Usage examples

```js
// returns arrays of all possible values
const expr = abmCron.parse('0 30 19 10-20 mar-sep MON-wed 2000,2050');
console.log(expr);
// =>
// [
//    [ 0 ],
//    [ 30 ],
//    [ 19 ],
//    [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ],
//    [ 3, 4, 5, 6, 7, 8, 9 ],
//    [ 1, 2, 3 ],
//    [ 2000, 2050 ]
// ]

// returns the date of the last run
const lastRun = abmCron.lastRun(expr);
console.log(lastRun);
// => 2000-09-20T19:30:00.000Z

// returns the date of the next run
const nextRun = abmCron.nextRun(expr);
console.log(nextRun);
// => 2050-03-14T19:30:00.000Z

// returns milliseconds passed from the previous run
const lastRunElapsed = abmCron.lastRunElapsed(expr);
console.log(lastRunElapsed);
// ~> 586979507253

// returns milliseconds remain until the next run
const nextRunRemains = abmCron.nextRunRemains(expr);
console.log(nextRunRemains);
// ~> 974441292747

// returns true if timestamp fits expression
const fits = abmCron.fits(expr, 2530899000000);
console.log(fits);
// => true
```

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