Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/octet-stream/minuette
âłA job scheduler with elegant syntax
https://github.com/octet-stream/minuette
chainable chainable-interface dependency-free javascript javascript-library job-scheduler library
Last synced: about 2 months ago
JSON representation
âłA job scheduler with elegant syntax
- Host: GitHub
- URL: https://github.com/octet-stream/minuette
- Owner: octet-stream
- License: mit
- Created: 2018-01-09T21:20:54.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T17:54:21.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T05:45:53.509Z (3 months ago)
- Topics: chainable, chainable-interface, dependency-free, javascript, javascript-library, job-scheduler, library
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/minuette
- Size: 682 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Minuette
âł A job scheduler with elegant syntax.
đ§ Project currently is still in development. Documentation and more features will be delivered soon!
[![devDependencies Status](https://david-dm.org/octet-stream/minuette/dev-status.svg)](https://david-dm.org/octet-stream/minuette?type=dev)
[![Build Status](https://travis-ci.org/octet-stream/minuette.svg?branch=master)](https://travis-ci.org/octet-stream/minuette)
[![Code Coverage](https://codecov.io/github/octet-stream/minuette/coverage.svg?branch=master)](https://codecov.io/github/octet-stream/minuette?branch=master)## Installation
You can install minuette using Yarn:
```
yarn add minuette
```or NPM:
```
npm i minuette
```## API
**Public**
### `constructor Minuette()`
Creates a new instance of minuette. Can be called as a regular function.
Note that minuette sets date and time relative to your system date/time parameters.#### Instance methods
##### `.once(dateOrDay) -> {Minuette}`
Sets a Job destination date using given day of week or date.
* **{string}** dateOrDay â timer destination date or day of week
##### `.at(time) -> {Minuette}`
Sets a time to run action.
* **{string}** time â destination time in 24 or 12-hour format
##### `.do(action, args, ctx) -> {Job}`
* **{function}** action â function to execute
* **{any[]?}** [args = []] â arguments to call function with
* **{any?}** [ctx = null] â "this" context to set to the function#### Usage
Minimal example of usage:
```js
import minuette from "minuette"// Will execute given functinon at next nearest friday at 21 hour.
minuette().once("friday").at("9pm").do(() => console.log("Hello, world!"))
```An example with absolute date:
```js
import minuette from "minuette"// Will execute given action at next 31 Oct, in 23:00
minuette().once("31 Oct").at("23:00").do(() => console.log("Boooo!"))
```You can optionally omit setting of a date or time. In this case, minuette will
use current date or time.For example:
```js
import minuette from "minuette"// Will execute this action in same day as `new Date()`
minuette().at("10pm").do(() => console.log("This message appears in 22 hour"))
```## Roadmap
- [x] Parsers for days of week, date and time (both for 12h and 24h formats);
- [x] `.once()`, `.at()` and `.do()` methods for proof-of-concept implementation;
- [x] Minimal implementation for Job that supports big idle intervals for setTimeout;
- [ ] `.repeat()` and `.each()` methods + supports of executing actions many times
- [ ] Documentation (in progress)
- [ ] Method `.in()` that will support alternative time or date setting relative to `Date.now()`
- [ ] Additional public API for Job: Methods `.pause()`, `.resume()`, `.stop()` and `.reset()`