|
1 | 1 | # cron-converter-u2q |
2 | 2 |
|
3 | | - |
| 3 | +[](https://github.com/rahu619/cron-converter-u2q) |
4 | 4 | [](https://www.npmjs.com/package/cron-converter-u2q) |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
| 5 | +[](LICENSE) |
| 6 | +[](https://github.com/rahu619/cron-converter-u2q/actions) |
| 7 | +[](https://github.com/rahu619/cron-converter-u2q/actions) |
| 8 | +[](https://www.typescriptlang.org/) |
| 9 | +[](https://www.npmjs.com/package/cron-converter-u2q) |
9 | 10 |
|
10 | 11 | [](https://www.npmjs.com/package/cron-converter-u2q) |
11 | 12 |
|
12 | | -Easily work with cron expressions using the `cron-converter-u2q` package. Effortlessly convert between Unix and Quartz formats and describe cron schedules in plain language. |
| 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. |
13 | 14 |
|
14 | | -### Features |
| 15 | +## ✨ Features |
15 | 16 |
|
16 | | -:arrows_counterclockwise: **Two-way conversion** |
| 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 |
17 | 22 |
|
18 | | -Effortlessly convert cron expressions: |
19 | | -- From Unix to Quartz |
20 | | -- From Quartz to Unix |
| 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.) |
21 | 28 |
|
22 | | -:memo: **Human-readable Descriptions** |
| 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 |
23 | 34 |
|
24 | | -Translate cron schedules into plain, understandable text: |
25 | | -- Example: `*/5 * * * *` -> "Every 5 minutes" |
| 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 |
26 | 40 |
|
27 | | -### Installation |
28 | | - |
29 | | -Using npm: |
| 41 | +## 📦 Installation |
30 | 42 |
|
31 | 43 | ```bash |
| 44 | +# Using npm |
32 | 45 | npm install cron-converter-u2q |
33 | | -``` |
34 | 46 |
|
35 | | -Using yarn: |
36 | | - |
37 | | -```bash |
| 47 | +# Using yarn |
38 | 48 | yarn add cron-converter-u2q |
39 | | -``` |
40 | 49 |
|
41 | | -### Usage |
| 50 | +# Using pnpm |
| 51 | +pnpm add cron-converter-u2q |
| 52 | +``` |
42 | 53 |
|
43 | | -Firstly, import the CronConverterU2Q module: |
| 54 | +## 🚀 Quick Start |
44 | 55 |
|
45 | | -```javascript |
46 | | -var cron_converter_u2q = require("cron-converter-u2q"); |
| 56 | +```typescript |
| 57 | +import { CronConverterU2Q } from 'cron-converter-u2q'; |
47 | 58 |
|
48 | | -var c2q = cron_converter_u2q.CronConverterU2Q; |
49 | | -``` |
| 59 | +// Convert Unix to Quartz |
| 60 | +const quartzExpression = CronConverterU2Q.unixToQuartz('5 * * * *'); |
| 61 | +console.log(quartzExpression); // "0 5 * * * ? *" |
50 | 62 |
|
51 | | -If you're using ES6 Modules |
| 63 | +// Convert Quartz to Unix |
| 64 | +const unixExpression = CronConverterU2Q.quartzToUnix('0 0 8 * * ?'); |
| 65 | +console.log(unixExpression); // "0 8 * * *" |
52 | 66 |
|
53 | | -```javascript |
54 | | -import { CronConverterU2QModule as c2q } from "cron-converter-u2q"; |
| 67 | +// Get human-readable description |
| 68 | +const description = CronConverterU2Q.describeUnix('*/5 * * * *'); |
| 69 | +console.log(description); // "Every 5 minutes" |
55 | 70 | ``` |
56 | 71 |
|
57 | | -### Conversion Methods |
| 72 | +## 📚 Examples |
58 | 73 |
|
59 | | -#### Convert from Unix to Quartz: |
| 74 | +### Basic Conversions |
60 | 75 |
|
61 | | -```javascript |
62 | | -const quartzExpression = c2q.unixToQuartz("5 * * * *"); |
63 | | -``` |
64 | | - |
65 | | -#### Convert from Quartz to Unix: |
| 76 | +```typescript |
| 77 | +// Unix to Quartz |
| 78 | +CronConverterU2Q.unixToQuartz('0 12 * * *'); // "0 0 12 * * ? *" |
| 79 | +CronConverterU2Q.unixToQuartz('*/15 * * * *'); // "0 */15 * * * ? *" |
66 | 80 |
|
67 | | -```javascript |
68 | | -const unixExpression = c2q.quartzToUnix("* */5 * ? * * *"); |
| 81 | +// Quartz to Unix |
| 82 | +CronConverterU2Q.quartzToUnix('0 0 8 * * ?'); // "0 8 * * *" |
| 83 | +CronConverterU2Q.quartzToUnix('0 */5 * * * ?'); // "*/5 * * * *" |
69 | 84 | ``` |
70 | 85 |
|
71 | | -### Description Methods |
72 | | - |
73 | | -You can now generate human-readable descriptions for Unix and Quartz cron expressions. |
| 86 | +### Human-readable Descriptions |
74 | 87 |
|
75 | | -#### Describe Unix Cron Expressions: |
| 88 | +```typescript |
| 89 | +// Unix format descriptions |
| 90 | +CronConverterU2Q.describeUnix('0 12 * * *'); // "At 12:00 PM" |
| 91 | +CronConverterU2Q.describeUnix('*/15 * * * *'); // "Every 15 minutes" |
76 | 92 |
|
77 | | -```javascript |
78 | | -const description = c2q.describeUnix("5 * * * *"); |
79 | | -console.log(description); // Outputs: "Every 5 minutes" |
| 93 | +// Quartz format descriptions |
| 94 | +CronConverterU2Q.describeQuartz('0 0 8 * * ?'); // "At 8:00 AM" |
| 95 | +CronConverterU2Q.describeQuartz('0 */5 * * * ?'); // "Every 5 minutes" |
80 | 96 | ``` |
81 | 97 |
|
82 | | -#### Describe Quartz Cron Expressions: |
| 98 | +## 🤝 Contributing |
83 | 99 |
|
84 | | -```javascript |
85 | | -const description = c2q.describeQuartz("0 0 8 * * ?"); |
86 | | -console.log(description); // Outputs: "At 8 o'clock" |
87 | | -``` |
| 100 | +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. |
| 101 | + |
| 102 | +1. Fork the repository |
| 103 | +2. Create your feature branch (`git checkout -b feature/amazing-feature`) |
| 104 | +3. Commit your changes (`git commit -m 'Add some amazing feature'`) |
| 105 | +4. Push to the branch (`git push origin feature/amazing-feature`) |
| 106 | +5. Open a Pull Request |
| 107 | + |
| 108 | +## 📄 License |
88 | 109 |
|
89 | | -## License |
90 | | -This project is licensed under the [MIT License](https://opensource.org/license/mit/) |
| 110 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
91 | 111 |
|
| 112 | +## 💬 Support |
92 | 113 |
|
93 | | -### Contributing |
94 | | -Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. |
| 114 | +- 📧 Email: rahu619@gmail.com |
| 115 | +- 💻 GitHub Issues: [Create an issue](https://github.com/rahu619/cron-converter-u2q/issues) |
| 116 | +- ⭐ Star the repository if you find it useful! |
95 | 117 |
|
96 | | -Please make sure to update tests as appropriate. |
| 118 | +## 🙏 Acknowledgments |
97 | 119 |
|
98 | | -### Support |
99 | | -Any feedback, suggestions, or contributions are highly appreciated! |
| 120 | +- Thanks to all contributors who have helped shape this project |
| 121 | +- Inspired by the need for a simple, reliable cron expression converter |
| 122 | +- Built with TypeScript for better developer experience |
100 | 123 |
|
0 commit comments