Skip to content

Commit

Permalink
Feature: add support for serializing a cron expression instance into …
Browse files Browse the repository at this point in the history
…a string (#214)

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string

* Fix #213 - add support for serializing a cron expression instance into a string
  • Loading branch information
regevbr authored Mar 4, 2021
1 parent 4d57cf4 commit 994d6ba
Show file tree
Hide file tree
Showing 19 changed files with 1,495 additions and 196 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
lib-cov
coverage
*.seed
*.log
*.csv
Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ cron-parser
[![Build Status](https://travis-ci.com/harrisiirak/cron-parser.svg?branch=master)](https://travis-ci.com/harrisiirak/cron-parser)
[![NPM version](https://badge.fury.io/js/cron-parser.png)](http://badge.fury.io/js/cron-parser)

Node.js library for parsing crontab instructions. It includes support for timezones and DST transitions.
Node.js library for parsing and manipulating crontab instructions. It includes support for timezones and DST transitions.

__Compatibility__
Node >= 0.8
Typescript <= 4.2

Setup
========
Expand All @@ -21,7 +25,7 @@ Supported format
│ │ │ │ │ |
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ │ └────────── day of month (1 - 31, L)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, optional)
Expand Down Expand Up @@ -107,6 +111,21 @@ try {
}
```

Manipulation

```javascript
var parser = require('cron-parser');

var interval = parser.parseExpression('0 7 * * 0-4');
var fields = JSON.parse(JSON.stringify(interval.fields)); // Fields is immutable
fields.hour = [8];
fields.minute = [29];
fields.dayOfWeek = [1,3,4,5,6,7];
var modifiedInterval = parser.fieldsToExpression(fields);
var cronString = modifiedInterval.stringify();
console.log(cronString); // "29 8 * * 1,3-7"
```

Options
========

Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"dependencies": {},
"development": {},
"main": "lib/parser.js",
"scripts": ["lib/parser.js", "lib/expression.js", "lib/date.js"]
"scripts": ["lib/parser.js", "lib/expression.js", "lib/date.js", "lib/field_compactor.js", "lib/field_stringify.js"]
}
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './types'
Loading

0 comments on commit 994d6ba

Please sign in to comment.