Git Product home page Git Product logo

rescript-node-cron's Introduction

rescript-cron

NPM version Build Status

Bindings for node-cron, a tool that allows you to execute something on a schedule. This is typically done using the cron syntax:

*    *    *    *    *    *
┬    ┬    ┬    ┬    ┬    ┬
│    │    │    │    │    │
│    │    │    │    │    └ day of week (0 - 6, or sun - sat), 0 is Sunday
│    │    │    │    └───── month (0 - 11, or jan - dec)
│    │    │    └────────── day of month (1 - 31)
│    │    └─────────────── hour (0 - 23)
│    └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, OPTIONAL)

Learn more about the syntax at crontab.guru (NB it does not have the seconds parameter and months start at 1 (this lib has 0-indexed months)).

Getting started

yarn add rescript-cron

Then add rescript-cron as a dependency to bsconfig.json:

"bs-dependencies": [
+  "rescript-cron"
]

Example

open RescriptCron

// Make a job that will fire every second when started
let job =
  CronJob.make(
    `CronString("* * * * * *"),
    _ => Js.log("Just doing my job"),
    (),
  );

// Firing every second, printing 'Just doing my job'
start(job);

let time =
  CronTime.make(`JsDate(Js.Date.fromString("2021-04-11T10:20:30Z")), ());

// setTime will stop the current job, and change when it will fire next
setTime(job, time);

// It will now fire once in april 2021
start(job);

The tests have more examples of how to use these bindings.

Contribute

  • If you find bugs or want to improve this library, feel free to open an issue or PR.
  • If you are upgrading any dependencies, please use yarn so yarn.lock is updated.
  • Try to adhere to Angular commit guidelines.

Alternatives

node-schedule is a JS library similar to node-cron (which this library is bindings for).

rescript-node-cron's People

Contributors

dependabot[bot] avatar glennsl avatar jasoons avatar mikaello avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

glennsl jasoons

rescript-node-cron's Issues

Build failing - something wrong with Date object passed to cron library

When the dates are sent to CronJob.make, they are not interpreted as Date in node-cron library, typeof <rescript-date> shows Object.

I don't know what is wrong, it seems like #JsDate(Js.Date.fromString(futureDate) does not result in a real Date, but something else.

Nevertheless, cron has advanced and is no longer using Moment, but have changed to Luxon, so this library probably needs a rewrite.

Looking at the TypeScript types could be of help: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/cron/index.d.ts

Unfortunately is the only ReScript/BuckleScript Luxon library I could find a bit outdated: https://github.com/davidgomes/bs-luxon

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • bs-moment 0.6.0
  • cron 1.8.2
  • @glennsl/rescript-jest 0.9.2
  • @ristostevcev/bs-odoc 1.3.0
  • moment 2.29.3
  • rescript 9.1.4
  • rescript-jest-date-mock 2.0.1
travis
.travis.yml
  • node 16.16

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.