diff --git a/compile.sh b/compile.sh index a258888..97c8cc7 100755 --- a/compile.sh +++ b/compile.sh @@ -21,6 +21,7 @@ mkdir -p "$PACK_DIR" # compile ts node_modules/.bin/tsc -p "$SOURCE_DIR" --outDir "$PACK_DIR" +# run tslint node_modules/tslint/bin/tslint --project "$SOURCE_DIR"/tsconfig.json --config "$SOURCE_DIR"/tslint.json # make commonjs bundle for ANDROID diff --git a/src/nativescript-intl-common.ts b/src/nativescript-intl-common.ts index 7bf7609..018fdcf 100644 --- a/src/nativescript-intl-common.ts +++ b/src/nativescript-intl-common.ts @@ -10,6 +10,7 @@ export const LONG = "long"; export const SHORT = "short"; export const TWODIGIT = "2-digit"; export const FULL = "full"; +export let resolvedPatterns = new Map(); export class DateTimeFormat implements intlDateTimeFormat { constructor(private locale?: string, private options?: intlDateTimeFormatOptions, private pattern?: string) { @@ -200,7 +201,12 @@ export class DateTimeFormat implements intlDateTimeFormat { if (this.pattern) { this._preparedPattern = this.pattern; } else { - this._preparedPattern = this.preparePattern(this.getCorrectPatternForLocale(), this.options); + if (resolvedPatterns.has({locale: this.locale, options: this.options})) { + this._preparedPattern = resolvedPatterns.get({locale: this.locale, options: this.options}); + } else { + this._preparedPattern = this.preparePattern(this.getCorrectPatternForLocale(), this.options); + resolvedPatterns.set({locale: this.locale, options: this.options}, this._preparedPattern); + } } } return this._preparedPattern;