Useful & super tiny ( less than 5KB ✔️) (❤️obvious dep on React & single function from date-fns
) hook to parse cron expression and get Date object with next cron occurrence.
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
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;
Parameter | Type | Description | Required |
---|---|---|---|
cronExpression | string | Cron expression to parse | Y |
options | useCronParserOptions | Set of hook options (skipValidation etc.) | N |
Option | Description | Default |
---|---|---|
skipValidation | Flag to skip/or not validation. | false |
Single function from date-fns
package & ❤️obvious peer dep on React only.
This package is fully tested with total coverage set to . If you found any issue please report it here.
Made with 💖 by Bartlomiej Zuber ([email protected]) and licensed under the MIT License