Skip to content

Commit

Permalink
Format with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymholt committed Jan 9, 2018
1 parent 4fb6126 commit 263b685
Show file tree
Hide file tree
Showing 30 changed files with 3,586 additions and 2,800 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Expand Up @@ -2,7 +2,7 @@ root = true

[*]
indent_style = space
indent_size = 4
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
Expand Down
17 changes: 10 additions & 7 deletions src/cronParser.ts
Expand Up @@ -15,9 +15,9 @@ export class CronParser {
}

/**
* Parses and normalizes a cron expression into an array of strings
* @returns {string[]}
*/
* Parses and normalizes a cron expression into an array of strings
* @returns {string[]}
*/
parse(): string[] {
let parsed = this.extractParts(this.expression);
this.normalize(parsed);
Expand All @@ -35,9 +35,9 @@ export class CronParser {

if (parsed.length < 5) {
throw new Error(
`Expression has only ${parsed.length} part${parsed.length == 1
? ""
: "s"}. At least 5 parts are required.`
`Expression has only ${parsed.length} part${
parsed.length == 1 ? "" : "s"
}. At least 5 parts are required.`
);
} else if (parsed.length == 5) {
//5 part cron so shift array past seconds element
Expand Down Expand Up @@ -234,7 +234,10 @@ export class CronParser {
this.assertNoInvalidCharacters("DOM", parsed[3]);
}

protected assertNoInvalidCharacters(partDescription: string, expression: string) {
protected assertNoInvalidCharacters(
partDescription: string,
expression: string
) {
// No characters other than 'L' or 'W' should remain after normalization
let invalidChars = expression.match(/[A-KM-VX-Z]+/gi);
if (invalidChars && invalidChars.length) {
Expand Down
34 changes: 16 additions & 18 deletions src/expressionDescriptor.ts
Expand Up @@ -15,19 +15,19 @@ export class ExpressionDescriptor {
i18n: Locale;

/**
* Converts a cron expression into a description a human can read
* @static
* @param {string} expression - The cron expression
* @param {IOptions} [{
* throwExceptionOnParseError = true,
* casingType = CasingTypeEnum.Sentence,
* verbose = false,
* dayOfWeekStartIndexZero = true,
* use24HourTimeFormat = false,
* locale = 'en'
* }={}]
* @returns {string}
*/
* Converts a cron expression into a description a human can read
* @static
* @param {string} expression - The cron expression
* @param {IOptions} [{
* throwExceptionOnParseError = true,
* casingType = CasingTypeEnum.Sentence,
* verbose = false,
* dayOfWeekStartIndexZero = true,
* use24HourTimeFormat = false,
* locale = 'en'
* }={}]
* @returns {string}
*/
static toString(
expression: string,
{
Expand Down Expand Up @@ -625,11 +625,9 @@ export class ExpressionDescriptor {
)}`;
}

return `${("00" + hour.toString()).substring(
hour.toString().length
)}:${("00" + minute.toString()).substring(
minute.toString().length
)}${second}${period}`;
return `${("00" + hour.toString()).substring(hour.toString().length)}:${(
"00" + minute.toString()
).substring(minute.toString().length)}${second}${period}`;
}

protected transformVerbosity(description: string, useVerboseFormat: boolean) {
Expand Down
30 changes: 15 additions & 15 deletions src/i18n/allLocales.ts
@@ -1,15 +1,15 @@
export { en } from "./locales/en" // English
export { de } from "./locales/de" // German
export { es } from "./locales/es" // Spanish
export { fr } from "./locales/fr" // French
export { it } from "./locales/it" // Italian
export { nl } from "./locales/nl" // Dutch
export { nb } from "./locales/nb" // Norwegian
export { sv } from "./locales/sv" // Swedish
export { pl } from "./locales/pl" // Polish
export { pt_BR } from "./locales/pt_BR" // Portuguese (Brazil)
export { ro } from "./locales/ro" // Romanian
export { ru } from "./locales/ru" // Russian
export { tr } from "./locales/tr" // Turkish
export { uk } from "./locales/uk" // Ukrainian
export { zh_CN } from "./locales/zh_CN" // Chinese (Simplified)
export { en } from "./locales/en"; // English
export { de } from "./locales/de"; // German
export { es } from "./locales/es"; // Spanish
export { fr } from "./locales/fr"; // French
export { it } from "./locales/it"; // Italian
export { nl } from "./locales/nl"; // Dutch
export { nb } from "./locales/nb"; // Norwegian
export { sv } from "./locales/sv"; // Swedish
export { pl } from "./locales/pl"; // Polish
export { pt_BR } from "./locales/pt_BR"; // Portuguese (Brazil)
export { ro } from "./locales/ro"; // Romanian
export { ru } from "./locales/ru"; // Russian
export { tr } from "./locales/tr"; // Turkish
export { uk } from "./locales/uk"; // Ukrainian
export { zh_CN } from "./locales/zh_CN"; // Chinese (Simplified)
14 changes: 8 additions & 6 deletions src/i18n/allLocalesLoader.ts
Expand Up @@ -2,11 +2,13 @@ import { Locale } from "./locale";
import * as allLocales from "./allLocales";

export class allLocalesLoader {
load(availableLocales: { [name: string]: Locale }) {
for (var property in allLocales) {
if (allLocales.hasOwnProperty(property)) {
availableLocales[property] = new ((allLocales as any)[property]) as Locale;;
}
}
load(availableLocales: { [name: string]: Locale }) {
for (var property in allLocales) {
if (allLocales.hasOwnProperty(property)) {
availableLocales[property] = new (allLocales as any)[
property
]() as Locale;
}
}
}
}
6 changes: 3 additions & 3 deletions src/i18n/enLocaleLoader.ts
Expand Up @@ -2,7 +2,7 @@ import { Locale } from "./locale";
import { en } from "./locales/en";

export class enLocaleLoader {
load(availableLocales: { [name: string]: Locale }) {
availableLocales["en"] = new en();
}
load(availableLocales: { [name: string]: Locale }) {
availableLocales["en"] = new en();
}
}
110 changes: 55 additions & 55 deletions src/i18n/locale.ts
@@ -1,58 +1,58 @@
export interface Locale {
// TODO: Circle back and use null/undefined aware types for optionals below in TypeScript 2.0: https://github.com/Microsoft/TypeScript/pull/7140
// TODO: These locale translations would be a good use for ES6 template strings except we sometimes concatenate multiple transactions together before
// doing the actual template replacement.
// TODO: Circle back and use null/undefined aware types for optionals below in TypeScript 2.0: https://github.com/Microsoft/TypeScript/pull/7140
// TODO: These locale translations would be a good use for ES6 template strings except we sometimes concatenate multiple transactions together before
// doing the actual template replacement.

use24HourTimeFormatByDefault(): boolean;
anErrorOccuredWhenGeneratingTheExpressionD(): string;
everyMinute(): string;
everyHour(): string;
atSpace(): string;
everyMinutebetweenX0AndX1(): string;
at(): string;
spaceAnd(): string;
everysecond(): string;
everyX0Seconds(): string;
secondsX0ThroughX1PastTheMinute(): string;
atX0SecondsPastTheMinute(): string;
atX0SecondsPastTheMinuteGt20(): string; //optional
everyX0Minutes(): string;
minutesX0ThroughX1PastTheHour(): string;
atX0MinutesPastTheHour(): string;
atX0MinutesPastTheHourGt20(): string; //optional
everyX0Hours(): string;
betweenX0AndX1(): string;
atX0(): string;
commaEveryDay(): string;
commaEveryX0daysOfTheWeek(): string;
commaX0ThroughX1(): string;
commaMonthX0ThroughMonthX1(): string //optional
commaYearX0ThroughYearX1(): string //optional
first(): string;
second(): string;
third(): string;
fourth(): string;
fifth(): string;
commaOnThe(): string;
spaceX0OfTheMonth(): string;
lastDay(): string;
commaOnTheLastX0OfTheMonth(): string;
commaOnlyOnX0(): string;
commaEveryX0Months(): string;
commaOnlyInX0(): string;
commaOnTheLastDayOfTheMonth(): string;
commaOnTheLastWeekdayOfTheMonth(): string;
firstWeekday(): string;
weekdayNearestDayX0(): string;
commaOnTheX0OfTheMonth(): string;
commaEveryX0Days(): string;
commaBetweenDayX0AndX1OfTheMonth(): string;
commaOnDayX0OfTheMonth(): string;
spaceAndSpace(): string;
commaEveryMinute(): string;
commaEveryHour(): string;
commaEveryX0Years(): string;
commaStartingX0(): string;
daysOfTheWeek(): string[];
monthsOfTheYear(): string[];
use24HourTimeFormatByDefault(): boolean;
anErrorOccuredWhenGeneratingTheExpressionD(): string;
everyMinute(): string;
everyHour(): string;
atSpace(): string;
everyMinutebetweenX0AndX1(): string;
at(): string;
spaceAnd(): string;
everysecond(): string;
everyX0Seconds(): string;
secondsX0ThroughX1PastTheMinute(): string;
atX0SecondsPastTheMinute(): string;
atX0SecondsPastTheMinuteGt20(): string; //optional
everyX0Minutes(): string;
minutesX0ThroughX1PastTheHour(): string;
atX0MinutesPastTheHour(): string;
atX0MinutesPastTheHourGt20(): string; //optional
everyX0Hours(): string;
betweenX0AndX1(): string;
atX0(): string;
commaEveryDay(): string;
commaEveryX0daysOfTheWeek(): string;
commaX0ThroughX1(): string;
commaMonthX0ThroughMonthX1(): string; //optional
commaYearX0ThroughYearX1(): string; //optional
first(): string;
second(): string;
third(): string;
fourth(): string;
fifth(): string;
commaOnThe(): string;
spaceX0OfTheMonth(): string;
lastDay(): string;
commaOnTheLastX0OfTheMonth(): string;
commaOnlyOnX0(): string;
commaEveryX0Months(): string;
commaOnlyInX0(): string;
commaOnTheLastDayOfTheMonth(): string;
commaOnTheLastWeekdayOfTheMonth(): string;
firstWeekday(): string;
weekdayNearestDayX0(): string;
commaOnTheX0OfTheMonth(): string;
commaEveryX0Days(): string;
commaBetweenDayX0AndX1OfTheMonth(): string;
commaOnDayX0OfTheMonth(): string;
spaceAndSpace(): string;
commaEveryMinute(): string;
commaEveryHour(): string;
commaEveryX0Years(): string;
commaStartingX0(): string;
daysOfTheWeek(): string[];
monthsOfTheYear(): string[];
}
2 changes: 1 addition & 1 deletion src/i18n/localeLoader.ts
@@ -1,5 +1,5 @@
import { Locale } from "./locale";

export interface LocaleLoader {
load(availableLocales: { [name: string]: Locale }):void;
load(availableLocales: { [name: string]: Locale }): void;
}

0 comments on commit 263b685

Please sign in to comment.