@bodar/totallylazy
Advanced tools
Comparing version 0.440.283 to 0.441.284
@@ -21,3 +21,2 @@ import { MonthFormat, Options, WeekdayFormat } from "./core"; | ||
export declare function months(locale: string, monthFormat?: MonthFormat | Options, native?: boolean): string[]; | ||
export declare function cleanValue(value: string): string; | ||
export declare type Weekday = Datum<number>; | ||
@@ -24,0 +23,0 @@ export declare class Weekdays extends DatumLookup<number> { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FromFormatStringWeekdayExtractor = exports.FromFormatStringMonthExtractor = exports.FromFormatStringDataExtractor = exports.NativeDataExtractor = exports.valueFromParts = exports.BaseDataExtractor = exports.exactFormat = exports.weekdays = exports.Weekdays = exports.cleanValue = exports.months = exports.Months = void 0; | ||
exports.FromFormatStringWeekdayExtractor = exports.FromFormatStringMonthExtractor = exports.FromFormatStringDataExtractor = exports.NativeDataExtractor = exports.valueFromParts = exports.BaseDataExtractor = exports.exactFormat = exports.weekdays = exports.Weekdays = exports.months = exports.Months = void 0; | ||
const arrays_1 = require("../arrays"); | ||
@@ -17,3 +17,3 @@ const core_1 = require("./core"); | ||
const number = functions_1.get(() => this.numerals.parse(value)); | ||
return isNaN(number) ? super.parse(cleanValue(value)) : number; | ||
return isNaN(number) ? super.parse(parsing_1.cleanValue(value)) : number; | ||
} | ||
@@ -60,14 +60,10 @@ static get(locale, additionalData = []) { | ||
if (native) | ||
return new NativeDataExtractor(locale, options, dates, 'month').extract().map(cleanValue); | ||
return new FromFormatStringMonthExtractor(locale, options, dates).extract().map(cleanValue); | ||
return new NativeDataExtractor(locale, options, dates, 'month').extract().map(parsing_1.cleanValue); | ||
return new FromFormatStringMonthExtractor(locale, options, dates).extract().map(parsing_1.cleanValue); | ||
})(); | ||
} | ||
exports.months = months; | ||
function cleanValue(value) { | ||
return value.replace(/\.$/, ''); | ||
} | ||
exports.cleanValue = cleanValue; | ||
class Weekdays extends parsing_1.DatumLookup { | ||
parse(value) { | ||
return super.parse(cleanValue(value)); | ||
return super.parse(parsing_1.cleanValue(value)); | ||
} | ||
@@ -106,4 +102,4 @@ static get(locale, additionalData = []) { | ||
if (native) | ||
return new NativeDataExtractor(locale, options, dates, 'weekday').extract().map(cleanValue); | ||
return new FromFormatStringWeekdayExtractor(locale, options, dates).extract().map(cleanValue); | ||
return new NativeDataExtractor(locale, options, dates, 'weekday').extract().map(parsing_1.cleanValue); | ||
return new FromFormatStringWeekdayExtractor(locale, options, dates).extract().map(parsing_1.cleanValue); | ||
})(); | ||
@@ -110,0 +106,0 @@ } |
@@ -81,3 +81,2 @@ import { NamedMatch } from "../characters"; | ||
static dataFor(locale: string, iso: string, currency: Currency): CurrencySymbolDatum[]; | ||
static readonly extraDelimiters: RegExp; | ||
parse(value: string, strategy?: MatchStrategy<string>): string; | ||
@@ -84,0 +83,0 @@ } |
@@ -110,3 +110,3 @@ "use strict"; | ||
super(data.map(d => { | ||
return ({ name: d.name.replace(CurrencySymbols.extraDelimiters, ''), value: d.value }); | ||
return ({ name: parsing_1.cleanValue(d.name), value: d.value }); | ||
}), collections_1.ascending); | ||
@@ -142,3 +142,3 @@ this.locale = locale; | ||
parse(value, strategy = parsing_1.infer(this.locale)) { | ||
return super.parse(value.replace(CurrencySymbols.extraDelimiters, ''), strategy); | ||
return super.parse(parsing_1.cleanValue(value), strategy); | ||
} | ||
@@ -149,3 +149,2 @@ } | ||
CurrencySymbols.generateAdditionalSymbols = ['$', '¥', '£']; | ||
CurrencySymbols.extraDelimiters = new RegExp(`[${parsing_1.boundaryDelimiters}]$`); | ||
const gbpSymbol = /[£GBP]+/; | ||
@@ -152,0 +151,0 @@ function symbolFor(locale, isoCurrency, hasNative = exports.hasNativeToParts) { |
{ | ||
"name": "@bodar/totallylazy", | ||
"version": "0.440.283", | ||
"version": "0.441.284", | ||
"description": "Totallylazy", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:bodar/totallylazy.js.git", |
@@ -45,6 +45,3 @@ import { NamedMatch, NamedRegExp } from "./characters"; | ||
get pattern(): string; | ||
get minMax(): { | ||
min: number; | ||
max: number; | ||
}; | ||
get max(): number; | ||
get characters(): string[]; | ||
@@ -78,3 +75,3 @@ } | ||
} | ||
export declare const boundaryDelimiters = ",."; | ||
export declare function cleanValue(value: string): string; | ||
export declare function atBoundaryOnly(pattern: string): string; | ||
@@ -81,0 +78,0 @@ export declare type Numeral = Datum<number>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.numberOf = exports.numberParser = exports.NumberParser = exports.separatorsOf = exports.mapIgnoreError = exports.numberPattern = exports.Spaces = exports.digits = exports.numberFormatter = exports.Numerals = exports.atBoundaryOnly = exports.boundaryDelimiters = exports.CachingParser = exports.all = exports.AllParser = exports.parsers = exports.or = exports.OrParser = exports.infer = exports.prefer = exports.uniqueMatch = exports.DatumLookup = exports.IdentityParser = exports.mappingParser = exports.MappingParser = exports.preProcess = exports.PreProcessor = exports.namedRegexParser = exports.NamedRegexParser = void 0; | ||
exports.numberOf = exports.numberParser = exports.NumberParser = exports.separatorsOf = exports.mapIgnoreError = exports.numberPattern = exports.Spaces = exports.digits = exports.numberFormatter = exports.Numerals = exports.atBoundaryOnly = exports.cleanValue = exports.CachingParser = exports.all = exports.AllParser = exports.parsers = exports.or = exports.OrParser = exports.infer = exports.prefer = exports.uniqueMatch = exports.DatumLookup = exports.IdentityParser = exports.mappingParser = exports.MappingParser = exports.preProcess = exports.PreProcessor = exports.namedRegexParser = exports.NamedRegexParser = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -100,10 +100,9 @@ const characters_1 = require("./characters"); | ||
get pattern() { | ||
const { min, max } = this.minMax; | ||
return `[${this.characters.join('')}]{${min},${max}}`; | ||
return `[${this.characters.join('')}]{1,${this.max}}`; | ||
} | ||
get minMax() { | ||
return this.data.reduce(({ min, max }, l) => { | ||
get max() { | ||
return this.data.reduce((max, l) => { | ||
const length = characters_1.characters(l.name).length; | ||
return { min: Math.min(min, length), max: Math.max(max, length) }; | ||
}, { min: Number.MAX_VALUE, max: Number.MIN_VALUE }); | ||
return Math.max(max, length); | ||
}, Number.MIN_VALUE); | ||
} | ||
@@ -216,5 +215,10 @@ get characters() { | ||
exports.CachingParser = CachingParser; | ||
exports.boundaryDelimiters = ',.'; | ||
const boundaryDelimiters = ',.'; | ||
const trailingDelimiters = new RegExp(`[${boundaryDelimiters}]$`); | ||
function cleanValue(value) { | ||
return value.replace(trailingDelimiters, ''); | ||
} | ||
exports.cleanValue = cleanValue; | ||
function atBoundaryOnly(pattern) { | ||
return `(?:^|\\s)${pattern}(?=[\\s${exports.boundaryDelimiters}]|$)`; | ||
return `(?:^|\\s)${pattern}(?=[\\s${boundaryDelimiters}]|$)`; | ||
} | ||
@@ -221,0 +225,0 @@ exports.atBoundaryOnly = atBoundaryOnly; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
439396
6447