1.0.3 • Published 2 years ago

use-cron-parser v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

use-cron-parser

react hook fully typed npm npm Build Status License Netlify Status

Useful & super tiny (less than 5KB ✔️) (❤️obvious dep on React & one add function from date-fns) hook to parse cron expression and get Date object with next cron occurrence.

Installation

npm i use-cron-parser --save

Alternatively you may use yarn:

yarn add use-cron-parser

Link to npm: https://www.npmjs.com/package/use-cron-parser

Usage

import React from 'react';
import { useCronParser }  from 'use-cron-parser';

const App = () => {
  const cronExpression = "10 * * * *";
  const cron = useCronParser(cronExpression);
  
  return (
    <div className="App">
      <div>{cronExpression}</div>
      <div>{cron.next()}</div>
    </div>
  );
}

export default App;

DEMO

Hook params

ParameterTypeDescriptionRequired
cronExpressionstringCron expression to parseY
optionsuseCronParserOptionsSet of hook options (skipValidation etc.)N

Options

OptionDescriptionDefault
skipValidationFlag to skip/or not validation.false

Dependencies Deps

One function from date-fns package & ❤️obvious peer dep on React only.

Reliability

This package is fully tested with total coverage set to Coverage Status. If you found any issue please report it here.

License

Made with :sparkling_heart: by Bartlomiej Zuber (bartlomiej.zuber@outlook.com) while traveling around the world, and licensed under the MIT License