cron-converter-u2q 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +52 -90
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,131 +1,93 @@
1
1
  # cron-converter-u2q
2
2
 
3
- [![Github Repo Stars](https://img.shields.io/github/stars/rahu619/cron-converter-u2q?style=social)](https://github.com/rahu619/cron-converter-u2q)
4
3
  [![NPM version](https://img.shields.io/npm/v/cron-converter-u2q)](https://www.npmjs.com/package/cron-converter-u2q)
4
+ [![npm downloads](https://img.shields.io/npm/dm/cron-converter-u2q)](https://www.npmjs.com/package/cron-converter-u2q)
5
5
  [![GitHub License](https://img.shields.io/github/license/rahu619/cron-converter-u2q?style=plastic)](LICENSE)
6
6
  [![GitHub Build](https://github.com/rahu619/cron-converter-u2q/actions/workflows/integration.yml/badge.svg?branch=main)](https://github.com/rahu619/cron-converter-u2q/actions)
7
- [![Github Release](https://github.com/rahu619/cron-converter-u2q/actions/workflows/release.yml/badge.svg?event=workflow_dispatch)](https://github.com/rahu619/cron-converter-u2q/actions)
8
- [![Github Top Language](https://img.shields.io/github/languages/top/rahu619/cron-converter-u2q?style=plastic)](https://www.typescriptlang.org/)
9
- [![npm downloads](https://img.shields.io/npm/dm/cron-converter-u2q)](https://www.npmjs.com/package/cron-converter-u2q)
10
-
11
- [![https://nodei.co/npm/cron-converter-u2q.png?downloads=true&downloadRank=true&stars=true](https://nodei.co/npm/cron-converter-u2q.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/cron-converter-u2q)
12
7
 
13
- A powerful TypeScript library for working with cron expressions. Effortlessly convert between Unix and Quartz formats, generate human-readable descriptions, and validate cron expressions with ease.
8
+ A lightweight, zero-dependency TypeScript utility to convert, validate, and describe cron expressions. Seamlessly translate between Unix and Quartz schedules, perform boundary checks, and render human-readable descriptions.
14
9
 
15
- ## ✨ Features
10
+ ---
16
11
 
17
- ### 🔄 Two-way Conversion
18
- - **Unix to Quartz**: Convert standard Unix cron expressions to Quartz format
19
- - **Quartz to Unix**: Convert Quartz cron expressions to standard Unix format
20
- - **Format Validation**: Built-in validation for both formats
21
- - **Error Handling**: Clear error messages for invalid expressions
12
+ ## 💡 Unix vs. Quartz Cron
22
13
 
23
- ### 📝 Human-readable Descriptions
24
- - **Natural Language**: Convert cron expressions to plain English
25
- - **Multiple Languages**: Support for different language descriptions
26
- - **Customizable**: Extend with your own description templates
27
- - **Detailed**: Includes all schedule details (minutes, hours, days, etc.)
14
+ | Specification | Fields | Format | Support |
15
+ | :--- | :--- | :--- | :--- |
16
+ | **Unix Cron** | 5 fields | `min hour dom month dow` | Standard POSIX (Linux, Crontab) |
17
+ | **Quartz Cron** | 6–7 fields | `sec min hour dom month dow [year]` | Java/Spring, AWS EventBridge, Azure |
28
18
 
29
- ### 🛠️ Developer Friendly
30
- - **TypeScript Support**: Full type definitions included
31
- - **Zero Dependencies**: Lightweight and fast
32
- - **Well Tested**: Comprehensive test coverage
33
- - **ES6 Modules**: Support for both CommonJS and ES6 imports
19
+ > [!NOTE]
20
+ > Quartz cron requires exactly one of `day-of-month` or `day-of-week` to contain `?` (when specifying a constraint on the other field) to prevent scheduling conflicts.
34
21
 
35
- ### 🔍 Validation & Error Handling
36
- - **Format Validation**: Ensures cron expressions are valid
37
- - **Range Checking**: Validates field values within acceptable ranges
38
- - **Clear Errors**: Descriptive error messages for debugging
39
- - **Type Safety**: TypeScript types for better development experience
22
+ ---
40
23
 
41
24
  ## 📦 Installation
42
25
 
43
26
  ```bash
44
- # Using npm
45
27
  npm install cron-converter-u2q
46
-
47
- # Using yarn
28
+ # or
48
29
  yarn add cron-converter-u2q
49
-
50
- # Using pnpm
30
+ # or
51
31
  pnpm add cron-converter-u2q
52
32
  ```
53
33
 
54
- ## 🚀 Quick Start
55
-
56
- ```typescript
57
- import { CronConverterU2Q, CronDescriberU2Q } from 'cron-converter-u2q';
58
-
59
- // Convert Unix to Quartz
60
- const quartzExpression = CronConverterU2Q.unixToQuartz('5 * * * *');
61
- console.log(quartzExpression); // "0 5 * * * ? *"
62
-
63
- // Convert Quartz to Unix
64
- const unixExpression = CronConverterU2Q.quartzToUnix('0 0 8 * * ?');
65
- console.log(unixExpression); // "0 8 * * *"
66
- // Get human-readable description
67
- const description = CronDescriberU2Q.describeUnix('*/5 * * * *');
68
- console.log(description); // "Every 5 minutes"
69
- ```
34
+ ---
70
35
 
71
- ## 📚 Examples
36
+ ## 🚀 Usage
72
37
 
73
- ### Basic Conversions
38
+ ### 1. Two-Way Conversion
39
+ Convert seamlessly between formats. Wildcards and aliases are normalized automatically.
74
40
 
75
41
  ```typescript
76
- // Unix to Quartz
77
- CronConverterU2Q.unixToQuartz('0 12 * * *'); // "0 0 12 * * ? *"
78
- CronConverterU2Q.unixToQuartz('*/15 * * * *'); // "0 */15 * * * ? *"
79
- // Quartz to Unix
80
- CronConverterU2Q.quartzToUnix('0 0 8 * * ?'); // "0 8 * * *"
81
- CronConverterU2Q.quartzToUnix('0 */5 * * * ?'); // "*/5 * * * *"
82
- ```
42
+ import { CronConverterU2Q } from 'cron-converter-u2q';
83
43
 
84
- ### Human-readable Descriptions
44
+ // Unix -> Quartz (adds 0 seconds)
45
+ CronConverterU2Q.unixToQuartz('*/15 * * * *'); // "0 */15 * * * * *"
46
+ CronConverterU2Q.unixToQuartz('0 12 * * 1'); // "0 0 12 ? * 2 *"
85
47
 
86
- ```typescript
87
- // Unix format descriptions
88
- CronDescriberU2Q.describeUnix('0 12 * * *'); // "At 12 o'clock"
89
- CronDescriberU2Q.describeUnix('*/15 * * * *'); // "Every 15 minutes"
90
-
91
- // Quartz format descriptions
92
- CronDescriberU2Q.describeQuartz('0 0 8 * * ?'); // "At 8 o'clock"
93
- CronDescriberU2Q.describeQuartz('0 */5 * * * ?'); // "Every 5 minutes"
48
+ // Quartz -> Unix (drops seconds/year)
49
+ CronConverterU2Q.quartzToUnix('0 0 8 * * ?'); // "0 8 * * *"
50
+ CronConverterU2Q.quartzToUnix('0 */5 * ? * 2'); // "*/5 * * * 1"
94
51
  ```
95
52
 
96
- ## 🤝 Contributing
53
+ ### 2. Validation
54
+ Perform boundary checks, detect syntax errors, and validate range limits.
97
55
 
98
- Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
56
+ ```typescript
57
+ import { CronValidatorU2Q } from 'cron-converter-u2q';
99
58
 
100
- 1. Fork the repository
101
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
102
- 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
103
- 4. Push to the branch (`git push origin feature/amazing-feature`)
104
- 5. Open a Pull Request
59
+ // Validate and throw detailed error messages
60
+ CronValidatorU2Q.validateUnix('60 * * * *'); // Throws: "Value 60 is out of range (0-59) for Minute"
61
+ CronValidatorU2Q.validateQuartz('0 */0 * ? * *'); // Throws: "Invalid step value in Minute: 0"
105
62
 
106
- ## 📄 License
63
+ // Boolean check
64
+ CronValidatorU2Q.isValidUnix('*/5 * * * *'); // true
65
+ CronValidatorU2Q.isValidQuartz('0 0 12 * * * *'); // true (both are allowed to be '*' in this package)
66
+ ```
107
67
 
108
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
68
+ ### 3. Human-Readable Descriptions
69
+ Render cron schedules into clear, natural English. Fully supports lists, ranges, step modifiers, and Quartz special symbols.
109
70
 
110
- ## 💬 Support
71
+ ```typescript
72
+ import { CronDescriberU2Q } from 'cron-converter-u2q';
111
73
 
112
- - 📧 Email: rahu619@gmail.com
113
- - 💻 GitHub Issues: [Create an issue](https://github.com/rahu619/cron-converter-u2q/issues)
114
- - Star the repository if you find it useful!
74
+ // Unix
75
+ CronDescriberU2Q.describeUnix('*/15 * * * *'); // "Every 15 minutes"
76
+ CronDescriberU2Q.describeUnix('0 12 1-5 * *'); // "At 12 o'clock from the 1st to the 5th of the month"
115
77
 
116
- ## 🙏 Acknowledgments
78
+ // Quartz
79
+ CronDescriberU2Q.describeQuartz('0 0 8,12 ? * 2-6 *'); // "At 8 and 12 o'clock from Monday to Friday"
80
+ CronDescriberU2Q.describeQuartz('0 0 0 L * ?'); // "At 0 o'clock on the last day of the month"
81
+ ```
117
82
 
118
- - Thanks to all contributors who have helped shape this project
119
- - Inspired by the need for a simple, reliable cron expression converter
120
- - Built with TypeScript for better developer experience
83
+ ---
121
84
 
122
- ## 📖 Specifications
85
+ ## 🤝 Contributing
123
86
 
124
- This library's conversion logic is grounded in the following official specifications:
87
+ Contributions are welcome! Please feel free to open issues or submit Pull Requests.
125
88
 
126
- - **POSIX IEEE Std 1003.1** – Defines the standard Unix cron expression format (5 fields: minute, hour, day-of-month, month, day-of-week).
127
- [https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html)
89
+ ---
128
90
 
129
- - **Quartz Scheduler** – Defines the extended Quartz cron trigger format (6–7 fields: seconds, minute, hour, day-of-month, month, day-of-week, optional year). Notably, exactly one of `day-of-month` or `day-of-week` must be `?` to avoid scheduling conflicts.
130
- [https://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html](https://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html)
91
+ ## 📄 License
131
92
 
93
+ This project is licensed under the MIT License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cron-converter-u2q",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Converts cron expressions between unix and quartz formats",
5
5
  "main": "lib/index.js",
6
6
  "types": "types/index.d.ts",