Skip to content

octet-stream/minuette

Repository files navigation

Minuette

⏳ A job scheduler with elegant syntax.

🚧 Project currently is still in development. Documentation and more features will be delivered soon!

devDependencies Status Build Status Code Coverage

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:

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:

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:

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

  • Parsers for days of week, date and time (both for 12h and 24h formats);
  • .once(), .at() and .do() methods for proof-of-concept implementation;
  • 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()