Cron by Lou
⏲️ Cron Quartz and Cron UNIX expression parser.
Usage
📦 Node
Install @lou.codes/cron
as a dependency:
pnpm add @lou.codes/cron# ornpm install @lou.codes/cron# oryarn add @lou.codes/cron
Import it and use it:
import { parseStringQuartz, parseCronQuartz } from "@lou.codes/cron";
const cron = parseStringQuartz("1-2/3 1-2,3,4 * 2W SEP,OCT 1L */10");/* { seconds: { every: 3, start: { from: 1, to: 2 } }, minutes: [{ from: 1, to: 2 }, 3, 4], hours: "*", dayOfMonth: { nearest: 2 }, month: ["SEP", "OCT"], dayOfWeek: { last: 1 }, year: { every: 10, start: "*" } }*/
parseCronQuartz(cron); // "1-2/3 1-2,3,4 * 2W SEP,OCT 1L */10"
🦕 Deno
Import @lou.codes/cron
using the npm:
prefix, and use it directly:
import { parseStringQuartz, parseCronQuartz } from "npm:@lou.codes/cron";
const cron = parseStringQuartz("1-2/3 1-2,3,4 * 2W SEP,OCT 1L */10");/* { seconds: { every: 3, start: { from: 1, to: 2 } }, minutes: [{ from: 1, to: 2 }, 3, 4], hours: "*", dayOfMonth: { nearest: 2 }, month: ["SEP", "OCT"], dayOfWeek: { last: 1 }, year: { every: 10, start: "*" } }*/
parseCronQuartz(cron); // "1-2/3 1-2,3,4 * 2W SEP,OCT 1L */10"
🌎 Browser
Import @lou.codes/cron
using esm.sh, and use it directly:
<script type="module"> import { parseStringQuartz, parseCronQuartz, } from "https://esm.sh/@lou.codes/cron";
const cron = parseStringQuartz("1-2/3 1-2,3,4 * 2W SEP,OCT 1L */10"); /* { seconds: { every: 3, start: { from: 1, to: 2 } }, minutes: [{ from: 1, to: 2 }, 3, 4], hours: "*", dayOfMonth: { nearest: 2 }, month: ["SEP", "OCT"], dayOfWeek: { last: 1 }, year: { every: 10, start: "*" } } */
parseCronQuartz(cron); // "1-2/3 1-2,3,4 * 2W SEP,OCT 1L */10"</script>
Useful links
- 📝 Documentation: TypeDoc generated documentation.
- ⏳ Changelog: List of changes between versions.
- ✅ Tests Coverage: Coveralls page with tests coverage.
To do
A big change is coming with stricter types and a better DX. Stay tuned.
Common
splitExpression
▸ splitExpression(source
): string
[]
Splits given string by spaces (even if multiple).
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
string
[]
An array with all elements of the given expression.
Example
splitExpression(" 1 2 3 4 5 "); // ["1", "2", "3", "4", "5"]splitExpression("1 2 3 4 5"); // ["1", "2", "3", "4", "5"]splitExpression("12345"); // ["12345"]
validateOr
▸ validateOr(...validations
): (value
: unknown
) => boolean
Run several validations in the same string, true if any is true.
Parameters
Name | Type | Description |
---|---|---|
...validations | readonly (value : unknown ) => boolean [] | List of validations. |
Returns
fn
Curried function with validations
in context.
▸ (value
): boolean
Parameters
Name | Type |
---|---|
value | unknown |
Returns
boolean
Example
validateOr([])("1"); // false
validateOr([item => item === "1", item => parseInt(item as string, 10) === 1])( "1",); // true
validateOr([item => item === "1", item => parseInt(item as string, 10) === 2])( "1",); // true
validateOr([item => item === "2", item => parseInt(item as string, 10) === 2])( "1",); // false
Other
CronDayOfMonth
Ƭ CronDayOfMonth:
CronNearestDayOfMonth
|
CronPartExtended
<CronDayOfMonthValue
>
Cron day of month.
CronDayOfMonthValue
Ƭ CronDayOfMonthValue: 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| 13
| 14
| 15
| 16
| 17
| 18
| 19
| 20
| 21
| 22
| 23
| 24
| 25
| 26
| 27
| 28
| 29
| 30
| 31
Cron day of the month value (1-31).
CronDayOfWeek
Ƭ CronDayOfWeek: CronLastValue
|
CronPartExtended
<CronDayOfWeekValue
>
| CronSpecificDayOfWeek
Cron day of week.
CronDayOfWeekValue
Ƭ CronDayOfWeekValue:
CronDayOfWeekValueNumber
|
CronDayOfWeekValueString
Cron day of week value (0-7 | SUN-SAT).
CronDayOfWeekValueNumber
Ƭ CronDayOfWeekValueNumber: 0
| 1
| 2
| 3
| 4
| 5
| 6
|
7
Cron day of week number value (0-7).
CronDayOfWeekValueString
Ƭ CronDayOfWeekValueString: "FRI"
| "MON"
| "SAT"
| "SUN"
|
"THU"
| "TUE"
| "WED"
Cron day of week string value (SUN-SAT).
CronEvery
Ƭ CronEvery: typeof CRON_EVERY
Cron every (*).
CronHours
Ƭ CronHours:
CronPart
<CronHoursValue
>
Cron hours.
CronHoursValue
Ƭ CronHoursValue: 0
| 1
| 2
| 3
| 4
| 5
| 6
| 7
|
8
| 9
| 10
| 11
| 12
| 13
| 14
| 15
| 16
| 17
|
18
| 19
| 20
| 21
| 22
| 23
Cron hours value (0-23).
CronLast
Ƭ CronLast: typeof CRON_LAST
Cron every (L).
CronLastValue
Ƭ CronLastValue: Object
Cron last object. It gets turned into the string ${last}L
.
Type declaration
Name | Type |
---|---|
last | CronDayOfWeekValueNumber |
CronList
Ƭ CronList<Value
>:
ReadonlyArray
<CronListItem
<Value
>>
Cron list (value1,value2,valueN).
Type parameters
Name |
---|
Value |
CronListItem
Ƭ CronListItem<Value
>:
CronRange
<Value
> |
CronSteps
<Value
> | Value
Cron list item.
Type parameters
Name |
---|
Value |
CronMinutes
Ƭ CronMinutes:
CronPart
<CronMinutesValue
>
Cron minutes.
CronMinutesValue
Ƭ CronMinutesValue: 0
| 1
| 2
| 3
| 4
| 5
| 6
| 7
|
8
| 9
| 10
| 11
| 12
| 13
| 14
| 15
| 16
| 17
|
18
| 19
| 20
| 21
| 22
| 23
| 24
| 25
| 26
| 27
|
28
| 29
| 30
| 31
| 32
| 33
| 34
| 35
| 36
| 37
|
38
| 39
| 40
| 41
| 42
| 43
| 44
| 45
| 46
| 47
|
48
| 49
| 50
| 51
| 52
| 53
| 54
| 55
| 56
| 57
|
58
| 59
Cron minutes value (0-59).
CronMonth
Ƭ CronMonth:
CronPart
<CronMonthValue
>
Cron month.
CronMonthValue
Ƭ CronMonthValue:
CronMonthValueNumber
|
CronMonthValueString
Cron month value (1-12 and JAN-DEC).
CronMonthValueNumber
Ƭ CronMonthValueNumber: 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
Cron month number value (1-12).
CronMonthValueString
Ƭ CronMonthValueString: "APR"
| "AUG"
| "DEC"
| "FEB"
| "JAN"
| "JUL"
| "JUN"
| "MAR"
| "MAY"
| "NOV"
| "OCT"
| "SEP"
Cron month string value (JAN-DEC).
CronNearest
Ƭ CronNearest: typeof CRON_NEAREST
Cron every (W).
CronNearestDayOfMonth
Ƭ CronNearestDayOfMonth: Object
Nearest day of month object It gets turned into the string ${nearest}W
.
Type declaration
Name | Type |
---|---|
nearest | CronDayOfMonthValue |
CronPart
Ƭ CronPart<Value
>: CronEvery
|
CronList
<Value
> |
CronRange
<Value
> |
CronSteps
<Value
> | Value
Cron part.
Type parameters
Name |
---|
Value |
CronPartExtended
Ƭ CronPartExtended<Value
>: CronLast
|
CronPart
<Value
> |
CronStartOrBlank
Cron part extended (used by CronDayOfWeek
and DayOfMonth
).
Type parameters
Name |
---|
Value |
CronQuartz
Ƭ CronQuartz: CronQuartzExtension
& CronUnix
Cron object (Quartz).
CronQuartzExtension
Ƭ CronQuartzExtension: Object
Cron expression parts coming with Quartz.
Type declaration
Name | Type | Description |
---|---|---|
seconds | CronSeconds | Cron CronSeconds object. |
year | CronYear | Cron CronYear object. |
CronRange
Ƭ CronRange<Value
>: Object
Cron range (from-to).
Type parameters
Name |
---|
Value |
Type declaration
Name | Type |
---|---|
from | Value |
to | Value |
CronSeconds
Ƭ CronSeconds:
CronPart
<CronSecondsValue
>
Cron seconds.
CronSecondsValue
Ƭ CronSecondsValue: 0
| 1
| 2
| 3
| 4
| 5
| 6
| 7
|
8
| 9
| 10
| 11
| 12
| 13
| 14
| 15
| 16
| 17
|
18
| 19
| 20
| 21
| 22
| 23
| 24
| 25
| 26
| 27
|
28
| 29
| 30
| 31
| 32
| 33
| 34
| 35
| 36
| 37
|
38
| 39
| 40
| 41
| 42
| 43
| 44
| 45
| 46
| 47
|
48
| 49
| 50
| 51
| 52
| 53
| 54
| 55
| 56
| 57
|
58
| 59
Cron seconds value (0-59).
CronSpecificDayOfWeek
Ƭ CronSpecificDayOfWeek: Object
Cron specific day of week object. It gets turned into the string
${day}#${week}
.
Type declaration
Name | Type |
---|---|
day | CronDayOfWeekValueNumber |
week | CronWeekValue |
CronStartOrBlank
Ƭ CronStartOrBlank: typeof
CRON_START_OR_BLANK
Cron start or blank value (?).
CronSteps
Ƭ CronSteps<Value
>: Object
Cron steps (start/every).
Type parameters
Name |
---|
Value |
Type declaration
Name | Type |
---|---|
every | number |
start | CronEvery | CronRange <Value > | Value |
CronUnix
Ƭ CronUnix: Object
Cron expression (UNIX).
Type declaration
Name | Type | Description |
---|---|---|
dayOfMonth | CronDayOfMonth | Cron CronDayOfMonth object. |
dayOfWeek | CronDayOfWeek | Cron CronDayOfWeek object. |
hours | CronHours | Cron CronHours object. |
minutes | CronMinutes | Cron CronMinutes object. |
month | CronMonth | Cron CronMonth object. |
CronValueParser
Ƭ CronValueParser<Value
>: Unary
<Value
, Maybe
<string
>>
Parses a value into a string or undefined
if invalid.
Type parameters
Name |
---|
Value |
CronWeekValue
Ƭ CronWeekValue: 1
| 2
| 3
| 4
| 5
Cron week value (1-5).
CronYear
Ƭ CronYear:
CronPart
<CronYearValue
>
Cron year.
CronYearValue
Ƭ CronYearValue: 1970
| 1971
| 1972
| 1973
| 1974
| 1975
|
1976
| 1977
| 1978
| 1979
| 1980
| 1981
| 1982
| 1983
|
1984
| 1985
| 1986
| 1987
| 1988
| 1989
| 1990
| 1991
|
1992
| 1993
| 1994
| 1995
| 1996
| 1997
| 1998
| 1999
|
2000
| 2001
| 2002
| 2003
| 2004
| 2005
| 2006
| 2007
|
2008
| 2009
| 2010
| 2011
| 2012
| 2013
| 2014
| 2015
|
2016
| 2017
| 2018
| 2019
| 2020
| 2021
| 2022
| 2023
|
2024
| 2025
| 2026
| 2027
| 2028
| 2029
| 2030
| 2031
|
2032
| 2033
| 2034
| 2035
| 2036
| 2037
| 2038
| 2039
|
2040
| 2041
| 2042
| 2043
| 2044
| 2045
| 2046
| 2047
|
2048
| 2049
| 2050
| 2051
| 2052
| 2053
| 2054
| 2055
|
2056
| 2057
| 2058
| 2059
| 2060
| 2061
| 2062
| 2063
|
2064
| 2065
| 2066
| 2067
| 2068
| 2069
| 2070
| 2071
|
2072
| 2073
| 2074
| 2075
| 2076
| 2077
| 2078
| 2079
|
2080
| 2081
| 2082
| 2083
| 2084
| 2085
| 2086
| 2087
|
2088
| 2089
| 2090
| 2091
| 2092
| 2093
| 2094
| 2095
|
2096
| 2097
| 2098
| 2099
Cron year value (1970-2099).
LimitTuple
Ƭ LimitTuple: readonly [lowerLimit: number, upperLimit: number]
Lower and upper limit of a number value.
StringValueParser
Ƭ StringValueParser<Value
>: Unary
<string
, Maybe
<Value
>>
Parses a string into a value of given type or undefined
if invalid
Type parameters
Name |
---|
Value |
CRON_EVERY
• Const
CRON_EVERY: "*"
CRON_LAST
• Const
CRON_LAST: "L"
CRON_LIST_SEPARATOR
• Const
CRON_LIST_SEPARATOR: ","
CRON_NEAREST
• Const
CRON_NEAREST: "W"
CRON_RANGE_SEPARATOR
• Const
CRON_RANGE_SEPARATOR: "-"
CRON_SPECIFIC_SEPARATOR
• Const
CRON_SPECIFIC_SEPARATOR: "#"
CRON_START_OR_BLANK
• Const
CRON_START_OR_BLANK: "?"
CRON_STEPS_SEPARATOR
• Const
CRON_STEPS_SEPARATOR: "/"
QUARTZ_DAY_OF_MONTH_POSITION
• Const
QUARTZ_DAY_OF_MONTH_POSITION: 3
QUARTZ_DAY_OF_WEEK_POSITION
• Const
QUARTZ_DAY_OF_WEEK_POSITION: 5
QUARTZ_HOURS_POSITION
• Const
QUARTZ_HOURS_POSITION: 2
QUARTZ_MINUTES_POSITION
• Const
QUARTZ_MINUTES_POSITION: 1
QUARTZ_MONTH_POSITION
• Const
QUARTZ_MONTH_POSITION: 4
QUARTZ_SECONDS_POSITION
• Const
QUARTZ_SECONDS_POSITION: 0
QUARTZ_YEAR_POSITION
• Const
QUARTZ_YEAR_POSITION: 6
UNIX_DAY_OF_MONTH_POSITION
• Const
UNIX_DAY_OF_MONTH_POSITION: 2
UNIX_DAY_OF_WEEK_POSITION
• Const
UNIX_DAY_OF_WEEK_POSITION: 4
UNIX_HOURS_POSITION
• Const
UNIX_HOURS_POSITION: 1
UNIX_MINUTES_POSITION
• Const
UNIX_MINUTES_POSITION: 0
UNIX_MONTH_POSITION
• Const
UNIX_MONTH_POSITION: 3
isCronSecondsValue
▸ isCronSecondsValue(value
): value is CronSecondsValue
Check if given is CronSecondsValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronSecondsValue
Returns true
if is CronSecondsValue
, false
otherwise.
Example
isCronSecondsValue(30); // trueisCronSecondsValue(80); // false
Parsers
parseCronDayOfMonth
▸ parseCronDayOfMonth(source
): Maybe
<string
>
Parses CronDayOfMonth
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | CronDayOfMonth | CronDayOfMonth to be parsed. |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronDayOfMonth(10); // "10"parseCronDayOfMonth("*"); // "*"parseCronDayOfMonth("?"); // "?"parseCronDayOfMonth({ every: 10, start: 2 }); // "2/10"parseCronDayOfMonth({ every: 10, start: "L" }); // "L/10"parseCronDayOfMonth([1, 2, 3, 4]); // "1,2,3,4"parseCronDayOfMonth({ from: 5, to: 10 }); // "5-10"parseCronDayOfMonth([1, 2, 3, 4, { from: 5, to: 10 }]); // "1,2,3,4,5-10"parseCronDayOfMonth("L"); // "L"parseCronDayOfMonth({ nearest: 1 }); // "1W"parseCronDayOfMonth({ every: 99, start: "*" }); // undefined
parseCronDayOfMonthValue
▸ parseCronDayOfMonthValue(...input
): Maybe
<string
>
Parses CronDayOfMonthValue
into a string.
Parameters
Name | Type |
---|---|
...input | Single <CronDayOfMonthValue > |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronDayOfMonthValue(1); // "1"parseCronDayOfMonthValue(31); // "31"parseCronDayOfMonthValue(99); // undefined
parseCronDayOfWeek
▸ parseCronDayOfWeek(source
): Maybe
<string
>
Parses CronDayOfWeek
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | CronDayOfWeek | CronDayOfWeek to be parsed. |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronDayOfWeek(6); // "6"parseCronDayOfWeek("*"); // "*"parseCronDayOfWeek("?"); // "?"parseCronDayOfWeek({ every: 6, start: 2 }); // "2/6"parseCronDayOfWeek({ every: 6, start: "L" }); // "L/6"parseCronDayOfWeek([1, 2, 3, 4]); // "1,2,3,4"parseCronDayOfWeek({ from: 1, to: 5 }); // "1-5"parseCronDayOfWeek({ from: "MON", to: "SAT" }); // "MON-SAT"parseCronDayOfWeek([1, 2, 3, { from: 5, to: 7 }]); // "1,2,3,5-7"parseCronDayOfWeek("L"); // "L"parseCronDayOfWeek({ last: 2 }); // "2L"parseCronDayOfWeek({ day: 1, week: 5 }); // "1#5"
parseCronDayOfWeekValue
▸ parseCronDayOfWeekValue(...input
): Maybe
<string
>
Parses CronDayOfWeekValue
into a string.
Parameters
Name | Type |
---|---|
...input | Single <CronDayOfWeekValue > |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronDayOfWeekValue(1); // "1"parseCronDayOfWeekValue(7); // "7"parseCronDayOfWeekValue(99); // undefined
parseCronEvery
▸ parseCronEvery(source
): undefined
| "*"
Parses a CronEvery
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | string | CronEvery to be parsed. |
Returns
undefined
| "*"
A string or undefined
if invalid.
Example
parseCronEvery("*"); // "*"parseCronEvery("💩"); // undefined
parseCronHours
▸ parseCronHours(source
): Maybe
<string
>
Parses CronHours
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | "*" | CronHoursValue | CronList <CronHoursValue > | CronRange <CronHoursValue > | CronSteps <CronHoursValue > | CronHours to be parsed. |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronHours(10); // "10"parseCronHours("*"); // "*"parseCronHours({ every: 10, start: 2 }); // "2/10"parseCronHours([1, 2, 3, 4]); // "1,2,3,4"parseCronHours({ from: 5, to: 10 }); // "5-10"parseCronHours([1, 2, 3, 4, { from: 5, to: 10 }]); // "1,2,3,4,5-10"
parseCronHoursValue
▸ parseCronHoursValue(...input
): Maybe
<string
>
Parses CronHoursValue
into a string.
Parameters
Name | Type |
---|---|
...input | Single <CronHoursValue > |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronHoursValue(10); // "10"parseCronHoursValue(23); // "23"parseCronHoursValue(99); // undefined
parseCronLast
▸ parseCronLast(source
): undefined
| "L"
Parses CronLast
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | string | CronLast to be parsed. |
Returns
undefined
| "L"
A string or undefined
if invalid.
Example
parseCronLast("L"); // "L"parseCronLast("💩"); // undefined
parseCronLastValue
▸ parseCronLastValue(source
): undefined
| string
Parses CronLastValue
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | CronLastValue | CronLastValue to be parsed. |
Returns
undefined
| string
A string or undefined
if invalid.
Example
parseCronLastValue({ last: 1 }); // "1L"parseCronLastValue({ last: 99 }); // undefined
parseCronList
▸ parseCronList(limit
): <Value>(parser
:
CronValueParser
<Value
>) => (source
:
CronList
<Value
>) => undefined
| string
Parses CronList
into a string.
Parameters
Name | Type | Description |
---|---|---|
limit | LimitTuple | LimitTuple to be used when parsing CronSteps . |
Returns
fn
Curried function with limit
on context.
▸ <Value
>(parser
): (source
:
CronList
<Value
>) => undefined
| string
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
parser | CronValueParser <Value > |
Returns
fn
▸ (source
): undefined
| string
Parameters
Name | Type |
---|---|
source | CronList <Value > |
Returns
undefined
| string
Example
const parseCronSecondsList = parseCronList([0, 59])(parseCronSecondsValue);
parseCronSecondsList([13, 10]); // "13,10",parseCronSecondsList([{ from: 13, to: 10 }, 10]); // "13-10,10",parseCronSecondsList([{ every: 10, start: 13 }, 10]); // "13/10,10",parseCronSecondsList([{ every: 10, start: { from: 13, to: 10 } }, 10]); // "13-10/10,10"parseCronSecondsList([{ every: 10, start: "L" }, 10]); // "L/10,10"parseCronSecondsList([]); // undefined
parseCronMinutes
▸ parseCronMinutes<Source
>(source
): Maybe
<string
>
Parses CronMinutes
into a string.
Type parameters
Name | Type |
---|---|
Source | extends number |
Parameters
Name | Type | Description |
---|---|---|
source | "*" | Source | CronList <Source > | CronRange <Source > | CronSteps <Source > | CronMinutes to be parsed. |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronMinutes(10); // "10"parseCronMinutes("*"); // "*"parseCronMinutes({ every: 10, start: 2 }); // "2/10"parseCronMinutes([1, 2, 3, 4]); // "1,2,3,4"parseCronMinutes({ from: 5, to: 10 }); // "5-10"parseCronMinutes([1, 2, 3, 4, { from: 5, to: 10 }]); // "1,2,3,4,5-10"
parseCronMinutesValue
▸ parseCronMinutesValue<Source
>(source
): Source
extends
CronMinutesValue
? `${Source}` :
Maybe
<"0"
| "1"
| "2"
| "3"
| "4"
| "5"
| "6"
| "7"
|
"8"
| "9"
| "10"
| "11"
| "12"
| "13"
| "14"
| "15"
|
"16"
| "17"
| "18"
| "19"
| "20"
| "21"
| "22"
| "23"
|
"24"
| "25"
| "26"
| "27"
| "28"
| "29"
| "30"
| "31"
|
"32"
| "33"
| "34"
| "35"
| "36"
| "37"
| "38"
| "39"
|
"40"
| "41"
| "42"
| "43"
| "44"
| "45"
| "46"
| "47"
|
"48"
| "49"
| "50"
| "51"
| "52"
| "53"
| "54"
| "55"
|
"56"
| "57"
| "58"
| "59"
>
Parses CronMinutesValue
into a string.
Type parameters
Name | Type |
---|---|
Source | extends number |
Parameters
Name | Type | Description |
---|---|---|
source | Source | CronMinutesValue to be parsed. |
Returns
Source
extends CronMinutesValue
?
`${Source}` : Maybe
<"0"
| "1"
| "2"
| "3"
| "4"
| "5"
|
"6"
| "7"
| "8"
| "9"
| "10"
| "11"
| "12"
| "13"
|
"14"
| "15"
| "16"
| "17"
| "18"
| "19"
| "20"
| "21"
|
"22"
| "23"
| "24"
| "25"
| "26"
| "27"
| "28"
| "29"
|
"30"
| "31"
| "32"
| "33"
| "34"
| "35"
| "36"
| "37"
|
"38"
| "39"
| "40"
| "41"
| "42"
| "43"
| "44"
| "45"
|
"46"
| "47"
| "48"
| "49"
| "50"
| "51"
| "52"
| "53"
|
"54"
| "55"
| "56"
| "57"
| "58"
| "59"
>
A string or undefined
if invalid.
Example
parseCronMinutesValue(0); // "0"parseCronMinutesValue(59); // "59"
parseCronMonth
▸ parseCronMonth(source
): Maybe
<string
>
Parses CronMonth
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | "*" | CronMonthValue | CronList <CronMonthValue > | CronRange <CronMonthValue > | CronSteps <CronMonthValue > | CronMonth to be parsed. |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronMonth(10); // "10"parseCronMonth("*"); // "*"parseCronMonth({ every: 6, start: 2 }); // "2/6"parseCronMonth([1, 2, 3, 4]); // "1,2,3,4"parseCronMonth({ from: 1, to: 5 }); // "1-5"parseCronMonth({ from: "JAN", to: "OCT" }); // "JAN-OCT"parseCronMonth([1, 2, 3, { from: 5, to: 7 }]); // "1,2,3,5-7"
parseCronMonthValue
▸ parseCronMonthValue(...input
): Maybe
<string
>
Parses CronMonthValue
into a string.
Parameters
Name | Type |
---|---|
...input | Single <CronMonthValue > |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronMonthValue(1); // "1"parseCronMonthValue(12); // "12"parseCronMonthValue(99); // undefined
parseCronNearestDayOfMonth
▸ parseCronNearestDayOfMonth(source
): undefined
| string
Parses CronNearestDayOfMonth
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | CronNearestDayOfMonth | CronNearestDayOfMonth to be parsed. |
Returns
undefined
| string
A string or undefined
if invalid.
Example
parseCronNearestDayOfMonth({ nearest: 2 }); // "2W"parseCronNearestDayOfMonth({ nearest: 99 }); // undefined
parseCronPart
▸ parseCronPart(limit
): <Value>(parser
:
CronValueParser
<Value
>) => (source
:
"*"
| Value
| CronList
<Value
> |
CronRange
<Value
> |
CronSteps
<Value
>) => Maybe
<string
>
Parses CronPart
into a string.
Parameters
Name | Type | Description |
---|---|---|
limit | LimitTuple | LimitTuple to be used when parsing CronSteps . |
Returns
fn
Curried function with limit
on context.
▸ <Value
>(parser
): (source
: "*"
| Value
|
CronList
<Value
> |
CronRange
<Value
> |
CronSteps
<Value
>) => Maybe
<string
>
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
parser | CronValueParser <Value > |
Returns
fn
▸ (source
): Maybe
<string
>
Parameters
Name | Type |
---|---|
source | "*" | Value | CronList <Value > | CronRange <Value > | CronSteps <Value > |
Returns
Maybe
<string
>
Example
const parseCronPartSeconds = parseCronPart([0, 59])(parseCronSecondsValue);
parseCronPartSeconds("*"); // "*"parseCronPartSeconds([13, 10]); // "13,10"parseCronPartSeconds([{ from: 13, to: 10 }, 10]); // "13-10,10"parseCronPartSeconds([{ every: 10, start: 13 }, 10]); // "13/10,10"parseCronPartSeconds([{ every: 99, start: 13 }, 10]); // undefinedparseCronPartSeconds([ { every: 10, start: { from: 13, to: 10 }, }, 10,]); // "13-10/10,10"parseCronPartSeconds([{ every: 10, start: "?" }, 10]); // "?/10,10"parseCronPartSeconds({ every: 10, start: 13 }); // "13/10"parseCronPartSeconds({ every: 10, start: { from: 13, to: 10 },}); // "13-10/10"parseCronPartSeconds({ every: 10, start: "?" }); // "?/10"parseCronPartSeconds({ from: 13, to: 10,}); // "13-10"
parseCronQuartz
▸ parseCronQuartz(source
): undefined
| string
Parses CronQuartz
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | CronQuartz | CronQuartz to be parsed. |
Returns
undefined
| string
A string or undefined
if invalid.
Example
parseCronQuartz({ dayOfMonth: "*", dayOfWeek: "*", hours: "*", minutes: "*", month: "*", seconds: "*", year: "*",}); // wanted: "* * * * * * *"parseCronQuartz({ dayOfMonth: [1, 2], dayOfWeek: [1, 2], hours: [1, 2], minutes: [1, 2], month: [1, 2], seconds: [1, 2], year: [1989, 2020],}); // "1,2 1,2 1,2 1,2 1,2 1,2 1989,2020"parseCronQuartz({ dayOfMonth: { from: 1, to: 2 }, dayOfWeek: { from: 1, to: 2 }, hours: { from: 1, to: 2 }, minutes: { from: 1, to: 2 }, month: { from: 1, to: 2 }, seconds: { from: 1, to: 2 }, year: { from: 1989, to: 2020 },}); // "1-2 1-2 1-2 1-2 1-2 1-2 1989-2020"parseCronQuartz({ dayOfMonth: { every: 2, start: 1 }, dayOfWeek: { every: 2, start: 1 }, hours: { every: 2, start: 1 }, minutes: { every: 2, start: 1 }, month: { every: 2, start: 1 }, seconds: { every: 2, start: 1 }, year: { every: 10, start: 1989 },}); // "1/2 1/2 1/2 1/2 1/2 1/2 1989/10"parseCronQuartz({ dayOfMonth: { nearest: 2 }, dayOfWeek: { last: 1 }, hours: "*", minutes: [{ from: 1, to: 2 }, 3, 4], month: ["SEP", "OCT"], seconds: { every: 3, start: { from: 1, to: 2 } }, year: { every: 10, start: "?" },}); // "1-2/3 1-2,3,4 * 2W SEP,OCT 1L ?/10",parseCronQuartz({ dayOfMonth: undefined, dayOfWeek: "*", hours: "*", minutes: "*", month: "*", seconds: "*", year: "*",}); // undefined,
parseCronRange
▸ parseCronRange<Value
>(parser
): (source
:
CronRange
<Value
>) => undefined
|
string
Parses CronRange
into a string.
Type parameters
Name |
---|
Value |
Parameters
Name | Type | Description |
---|---|---|
parser | CronValueParser <Value > | CronValueParser for CronRange . |
Returns
fn
Curried function with parser
in context.
▸ (source
): undefined
| string
Parameters
Name | Type |
---|---|
source | CronRange <Value > |
Returns
undefined
| string
Example
parseCronRangeSeconds({ from: 13, to: 10 }); // "13-10"parseCronRangeSeconds({ from: 999, to: 999 }); // undefined
parseCronSeconds
▸ parseCronSeconds(source
): Maybe
<string
>
Parses CronSeconds
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | "*" | CronSecondsValue | CronList <CronSecondsValue > | CronRange <CronSecondsValue > | CronSteps <CronSecondsValue > | CronSeconds to be parsed. |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronSeconds(10); // "10",parseCronSeconds("*"); // "*",parseCronSeconds({ every: 10, start: 2 }); // "2/10",parseCronSeconds([1, 2, 3, 4]); // "1,2,3,4",parseCronSeconds({ from: 5, to: 10 }); // "5-10",parseCronSeconds([1, 2, 3, 4, { from: 5, to: 10 }]); // "1,2,3,4,5-10",
parseCronSecondsValue
▸ parseCronSecondsValue(...input
): Maybe
<string
>
Parses CronSecondsValue
into a string.
Parameters
Name | Type |
---|---|
...input | Single <CronSecondsValue > |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronSecondsValue(10); // "10"parseCronSecondsValue(59); // "59"parseCronSecondsValue(99); // undefined
parseCronSpecificDayOfWeek
▸ parseCronSpecificDayOfWeek(source
): undefined
| string
Parses CronSpecificDayOfWeek
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | string | CronSpecificDayOfWeek | CronSpecificDayOfWeek to be parsed. |
Returns
undefined
| string
A string or undefined
if invalid.
Example
parseCronSpecificDayOfWeek({ day: 1, week: 5 }); // "1#5"parseCronSpecificDayOfWeek({ day: 99, week: 99 }); // undefined
parseCronStartOrBlank
▸ parseCronStartOrBlank(source
): undefined
| "?"
Parses CronStartOrBlank
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | string | CronStartOrBlank to be parsed. |
Returns
undefined
| "?"
A string or undefined
if invalid.
Example
parseCronStartOrBlank("?"); // "?"parseCronStartOrBlank("💩"); // undefined
parseCronSteps
▸ parseCronSteps(limit
): <Value>(parser
:
CronValueParser
<Value
>) => (source
:
CronSteps
<Value
>) => undefined
|
string
Parses CronSteps
into a string.
Parameters
Name | Type | Description |
---|---|---|
limit | LimitTuple | LimitTuple to be used when parsing CronSteps . |
Returns
fn
Curried function with limit
on context.
▸ <Value
>(parser
): (source
:
CronSteps
<Value
>) => undefined
|
string
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
parser | CronValueParser <Value > |
Returns
fn
▸ (source
): undefined
| string
Parameters
Name | Type |
---|---|
source | CronSteps <Value > |
Returns
undefined
| string
Example
const parseCronStepsSeconds = parseCronSteps([0, 59])(parseCronSecondsValue);
parseCronStepsSeconds({ every: 10, start: 13 }); // "13/10"parseCronStepsSeconds({ every: 99, start: 13 }); // undefinedparseCronStepsSeconds({ every: 10, start: { from: 13, to: 10 },}); // "13-10/10"parseCronStepsSeconds({ every: 10, start: "?" }); // "?/10"
parseCronUnix
▸ parseCronUnix(source
): undefined
| string
Parses Cron
(UNIX) into a string.
Parameters
Name | Type | Description |
---|---|---|
source | CronUnix | Cron (UNIX) to be parsed. |
Returns
undefined
| string
A string or undefined
if invalid.
Example
parseCronUnix({ dayOfMonth: "*", dayOfWeek: "*", hours: "*", minutes: "*", month: "*",}); // "* * * * *"parseCronUnix({ dayOfMonth: [1, 2], dayOfWeek: [1, 2], hours: [1, 2], minutes: [1, 2], month: [1, 2],}); // "1,2 1,2 1,2 1,2 1,2"parseCronUnix({ dayOfMonth: { from: 1, to: 2 }, dayOfWeek: { from: 1, to: 2 }, hours: { from: 1, to: 2 }, minutes: { from: 1, to: 2 }, month: { from: 1, to: 2 },}); // "1-2 1-2 1-2 1-2 1-2"parseCronUnix({ dayOfMonth: { every: 2, start: 1 }, dayOfWeek: { every: 2, start: 1 }, hours: { every: 2, start: 1 }, minutes: { every: 2, start: 1 }, month: { every: 2, start: 1 },}); // "1/2 1/2 1/2 1/2 1/2"parseCronUnix({ dayOfMonth: { nearest: 2 }, dayOfWeek: { last: 1 }, hours: "*", minutes: [{ from: 1, to: 2 }, 3, 4], month: ["SEP", "OCT"],}); // "1-2,3,4 * 2W SEP,OCT 1L"parseCronUnix({ dayOfMonth: undefined, dayOfWeek: "*", hours: "*", minutes: "*", month: "*",}); // undefined
parseCronYear
▸ parseCronYear(source
): Maybe
<string
>
Parses CronYear
into a string.
Parameters
Name | Type | Description |
---|---|---|
source | "*" | CronYearValue | CronList <CronYearValue > | CronRange <CronYearValue > | CronSteps <CronYearValue > | CronYear to be parsed. |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronYear(1989); // "1989"parseCronYear("*"); // "*"parseCronYear({ every: 10, start: 1989 }); // "1989/10"parseCronYear({ every: 10, start: "?" }); // "?/10"parseCronYear([1989, 1991, 2015, 2020]); // "1989,1991,2015,2020"parseCronYear({ from: 1989, to: 2020 }); // "1989-2020"parseCronYear([1989, 1989, 1991, 2015, 2020, { from: 1989, to: 2020 }]); // "1989,1991,2015,2020,1989-2020"
parseCronYearValue
▸ parseCronYearValue(...input
): Maybe
<string
>
Parses CronYearValue
into a string.
Parameters
Name | Type |
---|---|
...input | Single <CronYearValue > |
Returns
Maybe
<string
>
A string or undefined
if invalid.
Example
parseCronYearValue(1989); // "1989"parseCronYearValue(2022); // "2022"parseCronYearValue(1969); // undefinedparseCronYearValue(3000); // undefined
parseStringDayOfMonth
▸ parseStringDayOfMonth(source
):
Maybe
<CronDayOfMonth
>
Parses a string into a CronDayOfMonth
.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
Maybe
<CronDayOfMonth
>
A CronDayOfMonth
or undefined
if invalid.
Example
parseStringDayOfMonth("10"); // 10,parseStringDayOfMonth("*"); // "*",parseStringDayOfMonth("?"); // "?",parseStringDayOfMonth("2/10"); // { every: 10, start: 2 },parseStringDayOfMonth("?/10"); // { every: 10, start: "?" },parseStringDayOfMonth("1,2,3,4"); // [1, 2, 3, 4],parseStringDayOfMonth("5-10"); // { from: 5, to: 10 },parseStringDayOfMonth("1,2,3,4,5-10"); // [1, 2, 3, 4, { from: 5, to: 10 }],parseStringDayOfMonth("L"); // "L",parseStringDayOfMonth("1W"); // { nearest: 1 },parseStringDayOfMonth("INVALID"); // undefined,parseStringDayOfMonth("1,2,3,4,INVALID"); // undefined,
parseStringDayOfMonthValue
▸ parseStringDayOfMonthValue(...input
):
Maybe
<CronDayOfMonthValue
>
Parses a string into a CronDayOfMonthValue
.
Parameters
Name | Type |
---|---|
...input | Single <string > |
Returns
Maybe
<CronDayOfMonthValue
>
A CronDayOfMonthValue
or undefined
if invalid.
Example
parseStringDayOfMonthValue("13"); // 13parseStringDayOfMonthValue("99"); // undefined
parseStringDayOfWeek
▸ parseStringDayOfWeek(source
):
Maybe
<CronDayOfWeek
>
Parses a string into a CronDayOfWeek
.
Parameters
Name | Type | Description |
---|---|---|
source | string | String to be parsed. |
Returns
Maybe
<CronDayOfWeek
>
A CronDayOfWeek
or undefined
if invalid.
Example
parseStringDayOfWeek("6"); // 6parseStringDayOfWeek("*"); // "*"parseStringDayOfWeek("?"); // "?"parseStringDayOfWeek("2/6"); // { every: 6, start: 2 }parseStringDayOfWeek("?/6"); // { every: 6, start: "?" }parseStringDayOfWeek("1,2,3,4"); // [1, 2, 3, 4]parseStringDayOfWeek("1-5"); // { from: 1, to: 5 }parseStringDayOfWeek("MON-SAT"); // { from: "MON", to: "SAT" }parseStringDayOfWeek("mon-sat"); // { from: "MON", to: "SAT" }parseStringDayOfWeek("1,2,3,5-7"); // [1, 2, 3, { from: 5, to: 7 }]parseStringDayOfWeek("L"); // "L"parseStringDayOfWeek("2L"); // { last: 2 }parseStringDayOfWeek("1#5"); // { day: 1, week: 5 }parseStringDayOfWeek("INVALID"); // undefinedparseStringDayOfWeek("1,2,3,4,INVALID"); // undefined
parseStringDayOfWeekValue
▸ parseStringDayOfWeekValue(...input
):
Maybe
<CronDayOfWeekValue
>
Parses a string into a CronDayOfWeekValue
.
Parameters
Name | Type |
---|---|
...input | Single <string > |
Returns
Maybe
<CronDayOfWeekValue
>
A CronDayOfWeekValue
or undefined
if invalid.
Example
parseStringDayOfWeekValue("5"); // 5parseStringDayOfWeekValue("FRI"); // "FRI"parseStringDayOfWeekValue("fri"); // "FRI"parseStringDayOfWeekValue("8"); // undefinedparseStringDayOfWeekValue("IDK"); // undefined
parseStringHours
▸ parseStringHours(source
):
Maybe
<CronPart
<CronHoursValue
>>
Parses a string into a CronHours
.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
Maybe
<CronPart
<CronHoursValue
>>
A CronHours
or undefined
if invalid.
Example
parseStringHours("10"); // 10parseStringHours("*"); // "*"parseStringHours("2/10"); // { every: 10, start: 2 }parseStringHours("?/10"); // { every: 10, start: "?" }parseStringHours("1,2,3,4"); // [1, 2, 3, 4]parseStringHours("5-10"); // { from: 5, to: 10 }parseStringHours("1,2,3,4,5-10"); // [1, 2, 3, 4, { from: 5, to: 10 }]parseStringHours("INVALID"); // undefinedparseStringHours("1,2,3,4,INVALID"); // undefined
parseStringHoursValue
▸ parseStringHoursValue(...input
):
Maybe
<CronHoursValue
>
Parses a string into a CronHoursValue
.
Parameters
Name | Type |
---|---|
...input | Single <string > |
Returns
Maybe
<CronHoursValue
>
A CronHoursValue
or undefined
if invalid.
Example
parseStringHoursValue("10"); // 10parseStringHoursValue("25"); // undefined
parseStringLastValue
▸ parseStringLastValue(source
):
Maybe
<CronLastValue
>
Parses a string into a CronLastValue
.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
Maybe
<CronLastValue
>
A CronLastValue
or undefined
if invalid.
Example
parseStringLastValue("5L"); // { last: 5 }parseStringLastValue("INVALID"); // undefined
parseStringList
▸ parseStringList(limit
): <Value>(parser
:
StringValueParser
<Value
>) =>
(source
: string
) => undefined
|
CronList
<Value
>
Parses a string into a CronList
.
Parameters
Name | Type | Description |
---|---|---|
limit | LimitTuple | LimitTuple to be used when parsing CronSteps . |
Returns
fn
Curried function with limit
in context.
▸ <Value
>(parser
): (source
: string
) => undefined
|
CronList
<Value
>
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
parser | StringValueParser <Value > |
Returns
fn
▸ (source
): undefined
| CronList
<Value
>
Parameters
Name | Type |
---|---|
source | string |
Returns
undefined
| CronList
<Value
>
Example
parseStringListSeconds("13,10"); // [13, 10]parseStringListSeconds("13-10,10"); // [{ from: 13, to: 10 }, 10]parseStringListSeconds("13/10,10"); // [{ every: 10, start: 13 }, 10]parseStringListSeconds("13-10/10,10"); // [{ every: 10, start: { from: 13, to: 10 } }, 10]parseStringListSeconds("?/10,10"); // [{ every: 10, start: "?" }, 10]parseStringListSeconds("13,INVALID"); // undefinedparseStringListSeconds("INVALID"); // undefined
parseStringMinutes
▸ parseStringMinutes(source
):
Maybe
<CronPart
<CronMinutesValue
>>
Parses a string into a CronMinutes
.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
Maybe
<CronPart
<CronMinutesValue
>>
A CronMinutes
or undefined
if invalid.
Example
parseStringMinutes("10"); // 10parseStringMinutes("*"); // "*"parseStringMinutes("2/10"); // { every: 10, start: 2 }parseStringMinutes("?/10"); // { every: 10, start: "?" }parseStringMinutes("1,2,3,4"); // [1, 2, 3, 4]parseStringMinutes("5-10"); // { from: 5, to: 10 }parseStringMinutes("1,2,3,4,5-10"); // [1, 2, 3, 4, { from: 5, to: 10 }]parseStringMinutes("INVALID"); // undefinedparseStringMinutes("1,2,3,4,INVALID"); // undefined
parseStringMinutesValue
▸ parseStringMinutesValue(...input
):
Maybe
<CronMinutesValue
>
Parses a string into a CronMinutesValue
.
Parameters
Name | Type |
---|---|
...input | Single <string > |
Returns
Maybe
<CronMinutesValue
>
A CronMinutesValue
or undefined
if invalid.
Example
parseStringMinutesValue("10"); // 10parseStringMinutesValue("61"); // undefined
parseStringMonth
▸ parseStringMonth(source
):
Maybe
<CronPart
<CronMonthValue
>>
Parses a string into a CronMonth
.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
Maybe
<CronPart
<CronMonthValue
>>
A CronMonth
or undefined
if invalid.
Example
parseStringMonth("10"); // 10parseStringMonth("*"); // "*"parseStringMonth("2/6"); // { every: 6, start: 2 }parseStringMonth("?/6"); // { every: 6, start: "?" }parseStringMonth("1,2,3,4"); // [1, 2, 3, 4]parseStringMonth("1-5"); // { from: 1, to: 5 }parseStringMonth("JAN-OCT"); // { from: "JAN", to: "OCT" }parseStringMonth("jan-oct"); // { from: "JAN", to: "OCT" }parseStringMonth("1,2,3,5-7"); // [1, 2, 3, { from: 5, to: 7 }]parseStringMonth("INVALID"); // undefinedparseStringMonth("1,2,3,4,INVALID"); // undefined
parseStringMonthValue
▸ parseStringMonthValue(...input
):
Maybe
<CronMonthValue
>
Parses a string into a CronMonthValue
.
Parameters
Name | Type |
---|---|
...input | Single <string > |
Returns
Maybe
<CronMonthValue
>
A CronMonthValue
or undefined
if invalid.
Example
parseStringMonthValue("10"); // 10parseStringMonthValue("OCT"); // "OCT"parseStringMonthValue("oct"); // "OCT"parseStringMonthValue("24"); // undefinedparseStringMonthValue("IDK"); // undefined
parseStringNearestDayOfMonth
▸ parseStringNearestDayOfMonth(source
): undefined
|
CronNearestDayOfMonth
Parses a string into a CronNearestDayOfMonth
.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
undefined
|
CronNearestDayOfMonth
A CronNearestDayOfMonth
or undefined
if invalid.
Example
parseStringNearestDayOfMonth("2W"); // { nearest: 2 }parseStringNearestDayOfMonth("INVALID"); // undefined
parseStringPart
▸ parseStringPart(limit
): <Value>(parser
:
StringValueParser
<Value
>) =>
(source
: string
) =>
Maybe
<CronPart
<Value
>>
Parses a string into a CronPart
.
Parameters
Name | Type | Description |
---|---|---|
limit | LimitTuple | LimitTuple to be used when parsing CronSteps . |
Returns
fn
Curried function with limit
in context.
▸ <Value
>(parser
): (source
: string
) =>
Maybe
<CronPart
<Value
>>
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
parser | StringValueParser <Value > |
Returns
fn
▸ (source
): Maybe
<CronPart
<Value
>>
Parameters
Name | Type |
---|---|
source | string |
Returns
Maybe
<CronPart
<Value
>>
Example
const parseStringPartSeconds = parseStringPart([0, 59])( parseStringSecondsValue,);
parseStringPartSeconds("*"); // "*"parseStringPartSeconds("13,10"); // [13, 10]parseStringPartSeconds("13-10,10"); // [{ from: 13, to: 10 }, 10]parseStringPartSeconds("13/10,10"); // [{ every: 10, start: 13 }, 10]parseStringPartSeconds("?/10,10"); // [{ every: 10, start: "?" }, 10]parseStringPartSeconds("13/10"); // { every: 10, start: 13 }parseStringPartSeconds("?/10"); // { every: 10, start: "?" }parseStringPartSeconds("13-10"); // { from: 13, to: 10 }
parseStringQuartz
▸ parseStringQuartz(source
):
Maybe
<CronQuartz
>
Parses a string into a CronQuartz
.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
Maybe
<CronQuartz
>
A Cron
or undefined
if invalid.
Example
parseStringQuartz("* * * * * * *");// {// dayOfMonth: "*",// dayOfWeek: "*",// hours: "*",// minutes: "*",// month: "*",// seconds: "*",// year: "*",// }
parseStringQuartz("* * * * *");// {// dayOfMonth: "*",// dayOfWeek: "*",// hours: "*",// minutes: "*",// month: "*",// seconds: "*",// year: "*",// }
parseStringQuartz("1,2 1,2 1,2 1,2 1,2 1,2 1989,2020");// {// dayOfMonth: [1, 2],// dayOfWeek: [1, 2],// hours: [1, 2],// minutes: [1, 2],// month: [1, 2],// seconds: [1, 2],// year: [1989, 2020],// }
parseStringQuartz("1-2 1-2 1-2 1-2 1-2 1-2 1989-2020");// {// dayOfMonth: { from: 1, to: 2 },// dayOfWeek: { from: 1, to: 2 },// hours: { from: 1, to: 2 },// minutes: { from: 1, to: 2 },// month: { from: 1, to: 2 },// seconds: { from: 1, to: 2 },// year: { from: 1989, to: 2020 },// }
parseStringQuartz("1/2 1/2 1/2 1/2 1/2 1/2 1989/10");// {// dayOfMonth: { every: 2, start: 1 },// dayOfWeek: { every: 2, start: 1 },// hours: { every: 2, start: 1 },// minutes: { every: 2, start: 1 },// month: { every: 2, start: 1 },// seconds: { every: 2, start: 1 },// year: { every: 10, start: 1989 },// }
parseStringQuartz("1-2/3 1-2,3,4 * 2W SEP,OCT 1L ?/10");// {// dayOfMonth: { nearest: 2 },// dayOfWeek: { last: 1 },// hours: "*",// minutes: [{ from: 1, to: 2 }, 3, 4],// month: ["SEP", "OCT"],// seconds: { every: 3, start: { from: 1, to: 2 } },// year: { every: 10, start: "?" },// }
parseStringQuartz("INVALID"); // undefined
parseStringQuartzExpression
▸ parseStringQuartzExpression(source
): undefined
| readonly [string
,
string
, string
, string
, string
, string
, string
]
Parses given string expression.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
undefined
| readonly [string
, string
, string
, string
, string
,
string
, string
]
An array of 7 elements or undefined
if invalid.
Example
parseStringQuartzExpression("1 1 1 1 1"); // ["*", "1", "1", "1", "1", "1", "*"]parseStringQuartzExpression("1 1 1 1 1 1989"); // ["*", "1", "1", "1", "1", "1", "1989"]parseStringQuartzExpression("1 1 1 1 1 1"); // ["1", "1", "1", "1", "1", "1", "*"]parseStringQuartzExpression("1 1 1 1 1 1 1"); // ["1", "1", "1", "1", "1", "1", "1"]parseStringQuartzExpression(" 1 1 1 1 1 1 1 "); // ["1", "1", "1", "1", "1", "1", "1"]parseStringQuartzExpression("1 1 1 1 1 1 1 1"); // undefinedparseStringQuartzExpression("1 1 1 1"); // undefined
parseStringRange
▸ parseStringRange<Value
>(parser
): (source
: string
) =>
Maybe
<CronRange
<Value
>>
Parses a string into a CronRange
.
Type parameters
Name |
---|
Value |
Parameters
Name | Type | Description |
---|---|---|
parser | StringValueParser <Value > | StringValueParser for CronRange . |
Returns
fn
Curried function with parser
in context.
▸ (source
): Maybe
<CronRange
<Value
>>
Parameters
Name | Type |
---|---|
source | string |
Returns
Maybe
<CronRange
<Value
>>
Example
const parseStringRangeSeconds = parseStringRange(parseStringSecondsValue);
parseStringRangeSeconds("13-10"); // { from: 13, to: 10 }parseStringRangeSeconds("INVALID"); // undefined
parseStringSeconds
▸ parseStringSeconds(source
):
Maybe
<CronPart
<CronSecondsValue
>>
Parses a string into a CronSeconds
.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
Maybe
<CronPart
<CronSecondsValue
>>
A CronSeconds
or undefined
if invalid.
Example
parseStringSeconds("10"); // 10parseStringSeconds("*"); // "*"parseStringSeconds("2/10"); // { every: 10, start: 2 }parseStringSeconds("?/10"); // { every: 10, start: "?" }parseStringSeconds("1,2,3,4"); // [1, 2, 3, 4]parseStringSeconds("5-10"); // { from: 5, to: 10 }parseStringSeconds("1,2,3,4,5-10"); // [1, 2, 3, 4, { from: 5, to: 10 }]parseStringSeconds("INVALID"); // undefinedparseStringSeconds("1,2,3,4,INVALID"); // undefined
parseStringSecondsValue
▸ parseStringSecondsValue(...input
):
Maybe
<CronSecondsValue
>
Parses a string into a CronSecondsValue
.
Parameters
Name | Type |
---|---|
...input | Single <string > |
Returns
Maybe
<CronSecondsValue
>
A CronSecondsValue
or undefined
if invalid.
Example
parseStringSecondsValue("10"); // 10parseStringSecondsValue("61"); // undefined
parseStringSpecificDayOfWeek
▸ parseStringSpecificDayOfWeek(source
):
Maybe
<CronSpecificDayOfWeek
>
Parses a string into a CronSpecificDayOfWeek
.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
Maybe
<CronSpecificDayOfWeek
>
A CronSpecificDayOfWeek
or undefined
if invalid.
Example
parseStringSpecificDayOfWeek("1#5"); // { day: 1, week: 5 }parseStringSpecificDayOfWeek("INVALID"); // undefined
parseStringSteps
▸ parseStringSteps(limit
): <Value>(parser
:
StringValueParser
<Value
>) =>
(source
: string
) =>
Maybe
<CronSteps
<Value
>>
Parses a string into a CronSteps
.
Parameters
Name | Type | Description |
---|---|---|
limit | LimitTuple | LimitTuple for CronSteps . |
Returns
fn
Curried function with limit
in context.
▸ <Value
>(parser
): (source
: string
) =>
Maybe
<CronSteps
<Value
>>
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
parser | StringValueParser <Value > |
Returns
fn
▸ (source
): Maybe
<CronSteps
<Value
>>
Parameters
Name | Type |
---|---|
source | string |
Returns
Maybe
<CronSteps
<Value
>>
Example
const parseSecondsSteps = parseStringSteps([0, 59])(parseStringSecondsValue);
parseSecondsSteps("13/10"); // { every: 10, start: 13 }parseSecondsSteps("13-10/10"); // { every: 10, start: { from: 13, to: 10 } }parseSecondsSteps("?/10"); // { every: 10, start: "?" }parseSecondsSteps("13"); // undefined
parseStringUnix
▸ parseStringUnix(source
):
Maybe
<CronUnix
>
Parses a string into a CronUnix
.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
Maybe
<CronUnix
>
A CronUnix
or undefined
if invalid.
Example
parseStringUnix("* * * * *");// {// dayOfMonth: "*",// dayOfWeek: "*",// hours: "*",// minutes: "*",// month: "*",// }
parseStringUnix("* * * * *");// {// dayOfMonth: "*",// dayOfWeek: "*",// hours: "*",// minutes: "*",// month: "*",// }
parseStringUnix("1,2 1,2 1,2 1,2 1,2");// {// dayOfMonth: [1, 2],// dayOfWeek: [1, 2],// hours: [1, 2],// minutes: [1, 2],// month: [1, 2],// }
parseStringUnix("1-2 1-2 1-2 1-2 1-2");// {// dayOfMonth: { from: 1, to: 2 },// dayOfWeek: { from: 1, to: 2 },// hours: { from: 1, to: 2 },// minutes: { from: 1, to: 2 },// month: { from: 1, to: 2 },// }
parseStringUnix("1/2 1/2 1/2 1/2 1/2");// {// dayOfMonth: { every: 2, start: 1 },// dayOfWeek: { every: 2, start: 1 },// hours: { every: 2, start: 1 },// minutes: { every: 2, start: 1 },// month: { every: 2, start: 1 },// }
parseStringUnix("1-2,3,4 * 2W SEP,OCT 1L");// {// dayOfMonth: { nearest: 2 },// dayOfWeek: { last: 1 },// hours: "*",// minutes: [{ from: 1, to: 2 }, 3, 4],// month: ["SEP", "OCT"],// }
parseStringUnix("INVALID"); // undefined
parseStringUnixExpression
▸ parseStringUnixExpression(source
): undefined
| readonly [string
,
string
, string
, string
, string
]
Parses given expression or undefined if invalid.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
undefined
| readonly [string
, string
, string
, string
, string
]
An array of 5 elements or undefined
if invalid.
Example
parseStringUnixExpression("1 1 1 1 1"); // ["1", "1", "1", "1", "1"]parseStringUnixExpression(" 1 1 1 1 1 "); // ["1", "1", "1", "1", "1"]parseStringUnixExpression("1 1 1 1 1 1"); // undefinedparseStringUnixExpression("1 1 1 1"); // undefined
parseStringYear
▸ parseStringYear(source
):
Maybe
<CronPart
<CronYearValue
>>
Parses a string into a CronYear
.
Parameters
Name | Type | Description |
---|---|---|
source | string | string to be parsed. |
Returns
Maybe
<CronPart
<CronYearValue
>>
A CronYear
or undefined
if invalid.
Example
parseStringYear("1989"); // 1989,parseStringYear("*"); // "*",parseStringYear("1989/10"); // { every: 10, start: 1989 },parseStringYear("?/10"); // { every: 10, start: "?" },parseStringYear("1989,1991,2015,2020"); // [1989, 1991, 2015, 2020],parseStringYear("1989-2020"); // { from: 1989, to: 2020 },parseStringYear("1989,1991,2015,2020,1989-2020"); // [1989, 1991, 2015, 2020, { from: 1989, to: 2020 }],parseStringYear("INVALID"); // undefined,parseStringYear("1,2,3,4,INVALID"); // undefined,
parseStringYearValue
▸ parseStringYearValue(...input
):
Maybe
<CronYearValue
>
Parses a string into a CronYearValue
.
Parameters
Name | Type |
---|---|
...input | Single <string > |
Returns
Maybe
<CronYearValue
>
A CronYearValue
or undefined
if invalid.
Example
parseStringYearValue("1989"); // 1989parseStringYearValue("3000"); // undefined
Predicates
isCronDayOfMonthValue
▸ isCronDayOfMonthValue(value
): value is CronDayOfMonthValue
Check if given is CronDayOfMonthValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronDayOfMonthValue
Returns true
if is CronDayOfMonthValue
, false
otherwise.
Example
isCronDayOfMonthValue(13); // trueisCronDayOfMonthValue(50); // false
isCronDayOfWeekValue
▸ isCronDayOfWeekValue(value
): value is CronDayOfWeekValue
Check if given is CronDayOfWeekValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronDayOfWeekValue
Returns true
if is CronDayOfWeekValue
, false
otherwise.
Example
isCronDayOfWeekValue(5); // trueisCronDayOfWeekValue("FRI"); // trueisCronDayOfWeekValue("fri"); // trueisCronDayOfWeekValue("FRIDAY"); // falseisCronDayOfWeekValue(10); // falseisCronDayOfWeekValue("INVALID"); // false
isCronDayOfWeekValueNumber
▸ isCronDayOfWeekValueNumber(value
): value is CronDayOfWeekValueNumber
Check if given is CronDayOfWeekValueNumber
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronDayOfWeekValueNumber
Returns true
if is CronDayOfWeekValueNumber
, false
otherwise.
Example
isCronDayOfWeekValueNumber(5); // trueisCronDayOfWeekValueNumber(10); // falseisCronDayOfWeekValueNumber("INVALID"); // false
isCronDayOfWeekValueString
▸ isCronDayOfWeekValueString(value
): value is CronDayOfWeekValueString
Check if given is CronDayOfWeekValueString
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronDayOfWeekValueString
Returns true
if is CronDayOfWeekValueString
, false
otherwise.
Example
isCronDayOfWeekValueString("FRI"); // trueisCronDayOfWeekValueString("fri"); // trueisCronDayOfWeekValueString("FRIDAY"); // false
isCronEvery
▸ isCronEvery(value
): value is ”*”
Check if given is CronEvery
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is ”*”
Returns true
if is CronEvery
, false
otherwise.
Example
isCronEvery("*"); // trueisCronEvery("INVALID"); // false
isCronHoursValue
▸ isCronHoursValue(value
): value is CronHoursValue
Check if given is CronHoursValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronHoursValue
Returns true
if is CronHoursValue
, false
otherwise.
Example
isCronHoursValue(12); // trueisCronHoursValue(50); // false
isCronLast
▸ isCronLast(value
): value is “L”
Check if given is CronLast
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is “L”
Returns true
if is CronLast
, false
otherwise.
Example
isCronLast("L"); // trueisCronLast("INVALID"); // false
isCronLastValue
▸ isCronLastValue(value
): value is CronLastValue
Check if given is CronLastValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronLastValue
Returns true
if is CronLastValue
, false
otherwise.
Example
isCronLastValue({ last: 7 }); // trueisCronLastValue({ last: 100 }); // false
isCronList
▸ isCronList<Value
>(value
): value is CronList<Value>
Check if given is CronList
.
Type parameters
Name |
---|
Value |
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronList<Value>
Returns true
if is CronList
, false
otherwise.
Example
isCronList(["value", "value", "value"]); // true
isCronMinutesValue
▸ isCronMinutesValue(value
): value is CronMinutesValue
Check if given is CronMinutesValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronMinutesValue
Returns true
if is CronMinutesValue
, false
otherwise.
Example
isCronMinutesValue(30); // trueisCronMinutesValue(80); // false
isCronMonthValue
▸ isCronMonthValue(value
): value is CronMonthValue
Check if given is CronMonthValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronMonthValue
Returns true
if is CronMonthValue
, false
otherwise.
Example
isCronMonthValue(10); // trueisCronMonthValue("OCT"); // trueisCronMonthValue("oct"); // trueisCronMonthValue("OCTOBER"); // falseisCronMonthValue(50); // falseisCronMonthValue("INVALID"); // false
isCronMonthValueNumber
▸ isCronMonthValueNumber(value
): value is CronMonthValueNumber
Check if given is CronMonthValueNumber
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronMonthValueNumber
Returns true
if is CronMonthValueNumber
, false
otherwise.
Example
isCronMonthValueNumber(10); // trueisCronMonthValueNumber(50); // false
isCronMonthValueString
▸ isCronMonthValueString(value
): value is CronMonthValueString
Check if given is CronMonthValueString
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronMonthValueString
Returns true
if is CronMonthValueString
, false
otherwise.
Example
isCronMonthValueString("OCT"); // trueisCronMonthValueString("oct"); // trueisCronMonthValueString("INVALID"); // false
isCronNearestDayOfMonth
▸ isCronNearestDayOfMonth(value
): value is CronNearestDayOfMonth
Check if given is CronNearestDayOfMonth
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronNearestDayOfMonth
Returns true
if is CronNearestDayOfMonth
, false
otherwise.
Example
isCronNearestDayOfMonth({ nearest: 10 }); // trueisCronNearestDayOfMonth({ nearest: 100 }); // false
isCronRange
▸ isCronRange<Value
>(value
): value is CronRange<Value>
Check if given is CronRange
.
Type parameters
Name |
---|
Value |
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronRange<Value>
Returns true
if is CronRange
, false
otherwise.
Example
isCronRange({ from: 10, to: 20 }); // trueisCronRange({}); // false
isCronSpecificDayOfWeek
▸ isCronSpecificDayOfWeek(value
): value is CronSpecificDayOfWeek
Check if given is CronSpecificDayOfWeek
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronSpecificDayOfWeek
Returns true
if is CronSpecificDayOfWeek
, false
otherwise.
Example
isCronSpecificDayOfWeek({ day: 1, week: 5 }); // trueisCronSpecificDayOfWeek({ day: 9, week: 9 }); // false
isCronStartOrBlank
▸ isCronStartOrBlank(value
): value is ”?”
Check if given is CronStartOrBlank
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is ”?”
Returns true
if is CronStartOrBlank
, false
otherwise.
Example
isCronStartOrBlank("?"); // trueisCronStartOrBlank("INVALID"); // false
isCronSteps
▸ isCronSteps<Value
>(value
): value is CronSteps<Value>
Check if given is CronSteps
.
Type parameters
Name |
---|
Value |
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronSteps<Value>
Returns true
if is CronSteps
, false
otherwise.
Example
isCronSteps({ every: 10, start: "value" }); // trueisCronSteps({ every: "invalid" }); // false
isCronWeekValue
▸ isCronWeekValue(value
): value is CronWeekValue
Check if given is CronWeekValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronWeekValue
Returns true
if is CronWeekValue
, false
otherwise.
Example
isCronWeekValue(2); // trueisCronWeekValue(8); // false
isCronYearValue
▸ isCronYearValue(value
): value is CronYearValue
Check if given is CronYearValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is CronYearValue
Returns true
if is CronYearValue
, false
otherwise.
Example
isCronYearValue(1989); // trueisCronYearValue(3000); // false
isStringDayOfMonthValue
▸ isStringDayOfMonthValue(value
): value is string
Check if given is a string representing a CronDayOfMonthValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronDayOfMonthValue
, false
otherwise.
Example
isStringDayOfMonthValue("13"); // trueisStringDayOfMonthValue("50"); // false
isStringDayOfWeekValue
▸ isStringDayOfWeekValue(value
): boolean
Check if given is a string representing a CronDayOfWeekValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
boolean
Returns true
if is a string representing a CronDayOfWeekValue
, false
otherwise.
Example
isStringDayOfWeekValue("5"); // trueisStringDayOfWeekValue("FRI"); // trueisStringDayOfWeekValue("fri"); // trueisStringDayOfWeekValue("FRIDAY"); // falseisStringDayOfWeekValue("10"); // falseisStringDayOfWeekValue("INVALID"); // false
isStringDayOfWeekValueNumber
▸ isStringDayOfWeekValueNumber(value
): value is string
Check if given is a string representing a CronDayOfWeekValueNumber
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronDayOfWeekValueNumber
, false
otherwise.
Example
isStringDayOfWeekValueNumber("5"); // trueisStringDayOfWeekValueNumber("10"); // false
isStringHoursValue
▸ isStringHoursValue(value
): value is string
Check if given is a string representing a CronHoursValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronHoursValue
, false
otherwise.
Example
isStringHoursValue("12"); // trueisStringHoursValue("50"); // false
isStringLastValue
▸ isStringLastValue(value
): value is string
Check if given is a string representing a CronLastValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronLastValue
, false
otherwise.
Example
isStringLastValue("7L"); // trueisStringLastValue("7l"); // trueisStringLastValue("100L"); // falseisStringLastValue("INVALID"); // false
isStringList
▸ isStringList(value
): value is string
Check if given is a string representing a CronList
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronList
, false
otherwise.
Example
isStringList("value,value,value"); // trueisStringList("value"); // false
isStringMinutesValue
▸ isStringMinutesValue(value
): value is string
Check if given is a string representing a CronMinutesValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronMinutesValue
, false
otherwise.
Example
isStringMinutesValue("30"); // trueisStringMinutesValue("80"); // false
isStringMonthValue
▸ isStringMonthValue(value
): boolean
Check if given is a string representing a CronMonthValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
boolean
Returns true
if is a string representing a CronMonthValue
, false
otherwise.
Example
isStringMonthValue("10"); // trueisStringMonthValue("OCT"); // trueisStringMonthValue("oct"); // trueisStringMonthValue("OCTOBER"); // falseisStringMonthValue("50"); // falseisStringMonthValue("INVALID"); // false
isStringMonthValueNumber
▸ isStringMonthValueNumber(value
): value is string
Check if given is a string representing a CronMonthValueNumber
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronMonthValueNumber
, false
otherwise.
Example
isStringMonthValueNumber("10"); // trueisStringMonthValueNumber("50"); // false
isStringNearestDayOfMonth
▸ isStringNearestDayOfMonth(value
): value is string
Check if given is a string representing a CronNearestDayOfMonth
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronNearestDayOfMonth
, false
otherwise.
Example
isStringNearestDayOfMonth("10W"); // trueisStringNearestDayOfMonth("10w"); // trueisStringNearestDayOfMonth("100w"); // falseisStringNearestDayOfMonth("INVALID"); // false
isStringRange
▸ isStringRange(value
): value is string
Check if given is a string representing a CronRange
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronRange
, false
otherwise.
Example
isStringRange("10-20"); // trueisStringRange("13-10-1989"); // falseisStringRange("value"); // false
isStringSecondsValue
▸ isStringSecondsValue(value
): value is string
Check if given is a string representing a CronSecondsValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronSecondsValue
, false
otherwise.
Example
isStringSecondsValue("30"); // trueisStringSecondsValue("80"); // false
isStringSpecificDayOfWeek
▸ isStringSpecificDayOfWeek(value
): value is string
Check if given is a string representing a CronSpecificDayOfWeek
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronSpecificDayOfWeek
, false
otherwise.
Example
isStringSpecificDayOfWeek("1#5"); // trueisStringSpecificDayOfWeek("9#9"); // false
isStringSteps
▸ isStringSteps(value
): value is string
Check if given is a string representing a CronSteps
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronSteps
, false
otherwise.
Example
isStringSteps("value/value"); // trueisStringSteps("value/value/value"); // falseisStringSteps("value"); // false
isStringWeekValue
▸ isStringWeekValue(value
): value is string
Check if given is a string representing a CronWeekValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronWeekValue
, false
otherwise.
Example
isStringWeekValue("2"); // trueisStringWeekValue("8"); // false
isStringYearValue
▸ isStringYearValue(value
): value is string
Check if given is a string representing a CronYearValue
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | Value to check. |
Returns
value is string
Returns true
if is a string representing a CronYearValue
, false
otherwise.
Example
isStringYearValue("1989"); // trueisStringYearValue("3000"); // false
stringIncludesOnlyOnce
▸ stringIncludesOnlyOnce(search
): (value
: unknown
) => value is string
Checks if given search value appears just onces in given value.
Parameters
Name | Type | Description |
---|---|---|
search | string | Value to search. |
Returns
fn
Curried function with search
in context.
▸ (value
): value is string
Parameters
Name | Type |
---|---|
value | unknown |
Returns
value is string
Example
const includesCommaOnce = stringIncludesOnlyOnce(",");includesCommaOnce("value,value"); // trueincludesCommaOnce("value,value,value"); // falseincludesCommaOnce("value"); // false