@visulima/humanizer 3.0.0-alpha.10 → 3.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +140 -4
- package/dist/index.js +1 -3
- package/dist/language/af.d.ts +3 -2
- package/dist/language/af.js +1 -41
- package/dist/language/am.d.ts +3 -2
- package/dist/language/am.js +1 -33
- package/dist/language/ar.d.ts +3 -2
- package/dist/language/ar.js +1 -53
- package/dist/language/bg.d.ts +3 -2
- package/dist/language/bg.js +1 -42
- package/dist/language/bn.d.ts +3 -2
- package/dist/language/bn.js +1 -33
- package/dist/language/ca.d.ts +3 -2
- package/dist/language/ca.js +1 -41
- package/dist/language/ckb.d.ts +3 -2
- package/dist/language/ckb.js +1 -33
- package/dist/language/cs.d.ts +3 -2
- package/dist/language/cs.js +1 -53
- package/dist/language/cy.d.ts +3 -2
- package/dist/language/cy.js +1 -53
- package/dist/language/da.d.ts +3 -2
- package/dist/language/da.js +1 -45
- package/dist/language/de.d.ts +3 -2
- package/dist/language/de.js +1 -47
- package/dist/language/el.d.ts +3 -2
- package/dist/language/el.js +1 -53
- package/dist/language/en.d.ts +4 -3
- package/dist/language/en.js +1 -57
- package/dist/language/eo.d.ts +3 -2
- package/dist/language/eo.js +1 -47
- package/dist/language/es.d.ts +3 -2
- package/dist/language/es.js +1 -46
- package/dist/language/et.d.ts +3 -2
- package/dist/language/et.js +1 -47
- package/dist/language/eu.d.ts +3 -2
- package/dist/language/eu.js +1 -41
- package/dist/language/fa.d.ts +3 -2
- package/dist/language/fa.js +1 -38
- package/dist/language/fi.d.ts +3 -2
- package/dist/language/fi.js +1 -55
- package/dist/language/fo.d.ts +3 -2
- package/dist/language/fo.js +1 -48
- package/dist/language/fr.d.ts +3 -2
- package/dist/language/fr.js +1 -52
- package/dist/language/he.d.ts +3 -2
- package/dist/language/he.js +1 -52
- package/dist/language/hi.d.ts +3 -2
- package/dist/language/hi.js +1 -55
- package/dist/language/hr.d.ts +3 -2
- package/dist/language/hr.js +1 -110
- package/dist/language/hu.d.ts +3 -2
- package/dist/language/hu.js +1 -51
- package/dist/language/id.d.ts +3 -2
- package/dist/language/id.js +1 -50
- package/dist/language/is.d.ts +3 -2
- package/dist/language/is.js +1 -52
- package/dist/language/it.d.ts +3 -2
- package/dist/language/it.js +1 -51
- package/dist/language/ja.d.ts +3 -2
- package/dist/language/ja.js +1 -47
- package/dist/language/km.d.ts +3 -2
- package/dist/language/km.js +1 -57
- package/dist/language/kn.d.ts +3 -2
- package/dist/language/kn.js +1 -50
- package/dist/language/ko.d.ts +3 -2
- package/dist/language/ko.js +1 -42
- package/dist/language/ku.d.ts +3 -2
- package/dist/language/ku.js +1 -54
- package/dist/language/lo.d.ts +3 -2
- package/dist/language/lo.js +1 -58
- package/dist/language/lt.d.ts +3 -2
- package/dist/language/lt.js +1 -69
- package/dist/language/lv.d.ts +3 -2
- package/dist/language/lv.js +1 -55
- package/dist/language/mk.d.ts +3 -2
- package/dist/language/mk.js +1 -55
- package/dist/language/mn.d.ts +3 -2
- package/dist/language/mn.js +1 -46
- package/dist/language/mr.d.ts +3 -2
- package/dist/language/mr.js +1 -43
- package/dist/language/ms.d.ts +3 -2
- package/dist/language/ms.js +1 -49
- package/dist/language/nl.d.ts +3 -2
- package/dist/language/nl.js +1 -50
- package/dist/language/no.d.ts +3 -2
- package/dist/language/no.js +1 -47
- package/dist/language/pl.d.ts +3 -2
- package/dist/language/pl.js +1 -73
- package/dist/language/pt.d.ts +3 -2
- package/dist/language/pt.js +1 -50
- package/dist/language/ro.d.ts +3 -2
- package/dist/language/ro.js +1 -66
- package/dist/language/ru.d.ts +3 -2
- package/dist/language/ru.js +1 -59
- package/dist/language/sk.d.ts +3 -2
- package/dist/language/sk.js +1 -64
- package/dist/language/sl.d.ts +3 -2
- package/dist/language/sl.js +1 -138
- package/dist/language/sq.d.ts +3 -2
- package/dist/language/sq.js +1 -51
- package/dist/language/sr.d.ts +3 -2
- package/dist/language/sr.js +1 -83
- package/dist/language/sr_Latn.d.ts +3 -2
- package/dist/language/sr_Latn.js +1 -21
- package/dist/language/sv.d.ts +3 -2
- package/dist/language/sv.js +1 -49
- package/dist/language/sw.d.ts +3 -2
- package/dist/language/sw.js +1 -51
- package/dist/language/ta.d.ts +3 -2
- package/dist/language/ta.js +1 -54
- package/dist/language/te.d.ts +3 -2
- package/dist/language/te.js +1 -50
- package/dist/language/th.d.ts +3 -2
- package/dist/language/th.js +1 -44
- package/dist/language/tr.d.ts +3 -2
- package/dist/language/tr.js +1 -42
- package/dist/language/uk.d.ts +3 -2
- package/dist/language/uk.js +1 -61
- package/dist/language/ur.d.ts +3 -2
- package/dist/language/ur.js +1 -57
- package/dist/language/util/create-duration-language.d.ts +2 -2
- package/dist/language/util/create-duration-language.js +1 -33
- package/dist/language/util/duration/get-czech-or-slovak-form.d.ts +1 -1
- package/dist/language/util/duration/get-czech-or-slovak-form.js +1 -14
- package/dist/language/util/duration/get-slavic-form.d.ts +1 -1
- package/dist/language/util/duration/get-slavic-form.js +1 -17
- package/dist/language/util/validate-duration-language.d.ts +2 -2
- package/dist/language/util/validate-duration-language.js +1 -37
- package/dist/language/uz.d.ts +3 -2
- package/dist/language/uz.js +1 -43
- package/dist/language/uz_CYR.d.ts +3 -2
- package/dist/language/uz_CYR.js +1 -43
- package/dist/language/vi.d.ts +3 -2
- package/dist/language/vi.js +1 -34
- package/dist/language/zh_CN.d.ts +3 -2
- package/dist/language/zh_CN.js +1 -39
- package/dist/language/zh_TW.d.ts +3 -2
- package/dist/language/zh_TW.js +1 -39
- package/dist/packem_shared/duration-8-I9U1BK.js +1 -0
- package/dist/packem_shared/parseBytes-DQ0Kw2M8.js +1 -0
- package/dist/packem_shared/parseDuration-teGYCgRI.js +1 -0
- package/dist/packem_shared/types.d-DEgTgpjz.d.ts +130 -0
- package/package.json +20 -22
- package/dist/bytes.d.ts +0 -131
- package/dist/duration.d.ts +0 -3
- package/dist/packem_shared/duration-Br8Mr-Lj.js +0 -210
- package/dist/packem_shared/parseBytes-BkjYV2ut.js +0 -250
- package/dist/packem_shared/parseDuration-qO1Y4eiu.js +0 -111
- package/dist/parse-duration.d.ts +0 -9
- package/dist/types.d.ts +0 -130
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { durationLanguage, englishUnitMap } from '../language/en.js';
|
|
2
|
-
import validateDurationLanguage from '../language/util/validate-duration-language.js';
|
|
3
|
-
|
|
4
|
-
const STANDARD_UNIT_MEASURES = {
|
|
5
|
-
d: 864e5,
|
|
6
|
-
h: 36e5,
|
|
7
|
-
m: 6e4,
|
|
8
|
-
mo: 2629746e3,
|
|
9
|
-
ms: 1,
|
|
10
|
-
s: 1e3,
|
|
11
|
-
w: 6048e5,
|
|
12
|
-
y: 31556952e3
|
|
13
|
-
};
|
|
14
|
-
const ESCAPE_REGEX = /[-/\\^$*+?.()|[\]{}]/g;
|
|
15
|
-
const ISO_FORMAT = /^PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?$/i;
|
|
16
|
-
const COLON_FORMAT = /^(?:(\d+):)?(?:(\d+):)?(\d+)$/;
|
|
17
|
-
const NUMERIC_STRING_REGEX = /^[+-]?\d+(?:\.\d+)?$/;
|
|
18
|
-
const SIGN_PREFIX_REGEX = /^[-+]/;
|
|
19
|
-
const parseDuration = (value, options) => {
|
|
20
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
21
|
-
return void 0;
|
|
22
|
-
}
|
|
23
|
-
const { defaultUnit = "ms", language = durationLanguage } = options ?? {};
|
|
24
|
-
validateDurationLanguage(language);
|
|
25
|
-
const decimalSeparator = language.decimal ?? ".";
|
|
26
|
-
const groupSeparator = language.groupSeparator ?? ",";
|
|
27
|
-
const placeholderSeparator = language.placeholderSeparator ?? "_";
|
|
28
|
-
const escapedDecimal = decimalSeparator.replaceAll(ESCAPE_REGEX, String.raw`\$&`);
|
|
29
|
-
const escapedGroup = groupSeparator.replaceAll(ESCAPE_REGEX, String.raw`\$&`);
|
|
30
|
-
const escapedPlaceholder = placeholderSeparator.replaceAll(ESCAPE_REGEX, String.raw`\$&`);
|
|
31
|
-
const currentUnitMap = language.unitMap ?? englishUnitMap;
|
|
32
|
-
let processedValue = value.replaceAll(new RegExp(String.raw`(\d)[${escapedPlaceholder}${escapedGroup}](\d)`, "g"), "$1$2");
|
|
33
|
-
if (decimalSeparator !== ".") {
|
|
34
|
-
processedValue = processedValue.replace(escapedDecimal, ".");
|
|
35
|
-
}
|
|
36
|
-
if (NUMERIC_STRING_REGEX.test(value)) {
|
|
37
|
-
const numberOnly = Number.parseFloat(processedValue.trim());
|
|
38
|
-
if (!Number.isNaN(numberOnly)) {
|
|
39
|
-
const unitKey = currentUnitMap[defaultUnit];
|
|
40
|
-
if (unitKey !== void 0) {
|
|
41
|
-
return numberOnly * STANDARD_UNIT_MEASURES[unitKey];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return void 0;
|
|
45
|
-
}
|
|
46
|
-
const isoMatch = ISO_FORMAT.exec(value);
|
|
47
|
-
if (isoMatch) {
|
|
48
|
-
const hours = Number.parseInt(isoMatch[1] ?? "0", 10);
|
|
49
|
-
const minutes = Number.parseInt(isoMatch[2] ?? "0", 10);
|
|
50
|
-
const seconds = Number.parseInt(isoMatch[3] ?? "0", 10);
|
|
51
|
-
return hours * 36e5 + minutes * 6e4 + seconds * 1e3;
|
|
52
|
-
}
|
|
53
|
-
const colonMatch = COLON_FORMAT.exec(value);
|
|
54
|
-
if (colonMatch) {
|
|
55
|
-
let hours = 0;
|
|
56
|
-
let minutes = 0;
|
|
57
|
-
if (colonMatch[2] !== void 0) {
|
|
58
|
-
hours = Number.parseInt(colonMatch[1] ?? "0", 10);
|
|
59
|
-
minutes = Number.parseInt(colonMatch[2], 10);
|
|
60
|
-
} else if (colonMatch[1] !== void 0) {
|
|
61
|
-
minutes = Number.parseInt(colonMatch[1], 10);
|
|
62
|
-
}
|
|
63
|
-
const seconds = Number.parseInt(colonMatch[3] ?? "0", 10);
|
|
64
|
-
return hours * 36e5 + minutes * 6e4 + seconds * 1e3;
|
|
65
|
-
}
|
|
66
|
-
const currentUnitMapKeys = Object.keys(currentUnitMap);
|
|
67
|
-
const regexKeys = currentUnitMapKeys.toSorted((a, b) => b.length - a.length).map((k) => k.replaceAll(ESCAPE_REGEX, String.raw`\$&`)).join("|");
|
|
68
|
-
const durationRegex = new RegExp(String.raw`(-?\d*\.?\d+)\s*(${regexKeys})`, "gi");
|
|
69
|
-
let totalMs = 0;
|
|
70
|
-
let match;
|
|
71
|
-
let unitsFound = false;
|
|
72
|
-
let firstMatchIndex = -1;
|
|
73
|
-
let lastMatchEndIndex = 0;
|
|
74
|
-
durationRegex.lastIndex = 0;
|
|
75
|
-
while ((match = durationRegex.exec(processedValue)) !== null) {
|
|
76
|
-
if (!unitsFound) {
|
|
77
|
-
firstMatchIndex = match.index;
|
|
78
|
-
}
|
|
79
|
-
unitsFound = true;
|
|
80
|
-
const numberString = match[1];
|
|
81
|
-
const unitString = match[2];
|
|
82
|
-
if (!numberString || !unitString) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
const trimmedNumberString = numberString.trim();
|
|
86
|
-
const sign = trimmedNumberString.startsWith("-") ? -1 : 1;
|
|
87
|
-
const absNumberString = trimmedNumberString.replace(SIGN_PREFIX_REGEX, "");
|
|
88
|
-
const parsedNumber = Number.parseFloat(absNumberString);
|
|
89
|
-
const unitKey = currentUnitMap[unitString.toLowerCase()];
|
|
90
|
-
if (unitKey === void 0) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
const unitValue = STANDARD_UNIT_MEASURES[unitKey];
|
|
94
|
-
if (Number.isNaN(parsedNumber)) {
|
|
95
|
-
return void 0;
|
|
96
|
-
}
|
|
97
|
-
totalMs += sign * parsedNumber * unitValue;
|
|
98
|
-
lastMatchEndIndex = durationRegex.lastIndex;
|
|
99
|
-
}
|
|
100
|
-
const leadingText = processedValue.slice(0, firstMatchIndex).trim();
|
|
101
|
-
const trailingText = processedValue.slice(lastMatchEndIndex).trim();
|
|
102
|
-
if (unitsFound && (leadingText.length > 0 || trailingText.length > 0)) {
|
|
103
|
-
return void 0;
|
|
104
|
-
}
|
|
105
|
-
if (!unitsFound) {
|
|
106
|
-
return void 0;
|
|
107
|
-
}
|
|
108
|
-
return totalMs;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export { parseDuration as default };
|
package/dist/parse-duration.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ParseDurationOptions } from "./types.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Parses a human-readable duration string into milliseconds using specified language units.
|
|
4
|
-
* @param value The string to parse (e.g., "1h 20min", "2 days", "-3 hafta").
|
|
5
|
-
* @param options Optional configuration including language and default unit.
|
|
6
|
-
* @returns The duration in milliseconds, or undefined if the string cannot be parsed.
|
|
7
|
-
*/
|
|
8
|
-
declare const parseDuration: (value: string, options?: ParseDurationOptions) => number | undefined;
|
|
9
|
-
export default parseDuration;
|
package/dist/types.d.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
interface BytesOptions {
|
|
2
|
-
/**
|
|
3
|
-
* The base to use for the conversion.
|
|
4
|
-
* @default 2
|
|
5
|
-
*/
|
|
6
|
-
base?: 2 | 10;
|
|
7
|
-
/**
|
|
8
|
-
* The default locale to use for parsing/formatting the output.
|
|
9
|
-
* @default 'en-US'
|
|
10
|
-
*/
|
|
11
|
-
locale?: IntlLocale;
|
|
12
|
-
/**
|
|
13
|
-
* The unit to use for the output.
|
|
14
|
-
* @default "metric"
|
|
15
|
-
*/
|
|
16
|
-
units?: "iec_octet" | "iec" | "metric_octet" | "metric";
|
|
17
|
-
}
|
|
18
|
-
export type IntlLocale = "af-NA" | "af" | "agq" | "ak" | "am" | "ar-AE" | "ar-BH" | "ar-DJ" | "ar-DZ" | "ar-EG" | "ar-EH" | "ar-ER" | "ar-IL" | "ar-IQ" | "ar-JO" | "ar-KM" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MA" | "ar-MR" | "ar-OM" | "ar-PS" | "ar-QA" | "ar-SA" | "ar-SD" | "ar-SO" | "ar-SS" | "ar-SY" | "ar-TD" | "ar-TN" | "ar-YE" | "ar" | "as" | "asa" | "ast" | "az-Cyrl" | "az-Latn" | "az" | "bas" | "be-tarask" | "be" | "bem" | "bez" | "bg" | "bm" | "bn-IN" | "bn" | "bo-IN" | "bo" | "br" | "brx" | "bs-Cyrl" | "bs-Latn" | "bs" | "ca-AD" | "ca-ES-valencia" | "ca-FR" | "ca-IT" | "ca" | "ccp-IN" | "ccp" | "ce" | "ceb" | "cgg" | "chr" | "ckb-IR" | "ckb" | "cs" | "cy" | "da-GL" | "da" | "dav" | "de-AT" | "de-BE" | "de-CH" | "de-IT" | "de-LI" | "de-LU" | "de" | "dje" | "doi" | "dsb" | "dua" | "dyo" | "dz" | "ebu" | "ee-TG" | "ee" | "el-CY" | "el" | "en-001" | "en-150" | "en-AE" | "en-AG" | "en-AI" | "en-AS" | "en-AT" | "en-AU" | "en-BB" | "en-BE" | "en-BI" | "en-BM" | "en-BS" | "en-BW" | "en-BZ" | "en-CA" | "en-CC" | "en-CH" | "en-CK" | "en-CM" | "en-CX" | "en-CY" | "en-DE" | "en-DG" | "en-DK" | "en-DM" | "en-ER" | "en-FI" | "en-FJ" | "en-FK" | "en-FM" | "en-GB" | "en-GD" | "en-GG" | "en-GH" | "en-GI" | "en-GM" | "en-GU" | "en-GY" | "en-HK" | "en-IE" | "en-IL" | "en-IM" | "en-IN" | "en-IO" | "en-JE" | "en-JM" | "en-KE" | "en-KI" | "en-KN" | "en-KY" | "en-LC" | "en-LR" | "en-LS" | "en-MG" | "en-MH" | "en-MO" | "en-MP" | "en-MS" | "en-MT" | "en-MU" | "en-MW" | "en-MY" | "en-NA" | "en-NF" | "en-NG" | "en-NL" | "en-NR" | "en-NU" | "en-NZ" | "en-PG" | "en-PH" | "en-PK" | "en-PN" | "en-PR" | "en-PW" | "en-RW" | "en-SB" | "en-SC" | "en-SD" | "en-SE" | "en-SG" | "en-SH" | "en-SI" | "en-SL" | "en-SS" | "en-SX" | "en-SZ" | "en-TC" | "en-TK" | "en-TO" | "en-TT" | "en-TV" | "en-TZ" | "en-UG" | "en-UM" | "en-VC" | "en-VG" | "en-VI" | "en-VU" | "en-WS" | "en-ZA" | "en-ZM" | "en-ZW" | "en" | "eo" | "es-419" | "es-AR" | "es-BO" | "es-BR" | "es-BZ" | "es-CL" | "es-CO" | "es-CR" | "es-CU" | "es-DO" | "es-EA" | "es-EC" | "es-GQ" | "es-GT" | "es-HN" | "es-IC" | "es-MX" | "es-NI" | "es-PA" | "es-PE" | "es-PH" | "es-PR" | "es-PY" | "es-SV" | "es-US" | "es-UY" | "es-VE" | "es" | "et" | "eu" | "ewo" | "fa-AF" | "fa" | "ff-Adlm-BF" | "ff-Adlm-CM" | "ff-Adlm-GH" | "ff-Adlm-GM" | "ff-Adlm-GW" | "ff-Adlm-LR" | "ff-Adlm-MR" | "ff-Adlm-NE" | "ff-Adlm-NG" | "ff-Adlm-SL" | "ff-Adlm-SN" | "ff-Adlm" | "ff-Latn-BF" | "ff-Latn-CM" | "ff-Latn-GH" | "ff-Latn-GM" | "ff-Latn-GN" | "ff-Latn-GW" | "ff-Latn-LR" | "ff-Latn-MR" | "ff-Latn-NE" | "ff-Latn-NG" | "ff-Latn-SL" | "ff-Latn" | "ff" | "fi" | "fil" | "fo-DK" | "fo" | "fr-BE" | "fr-BF" | "fr-BI" | "fr-BJ" | "fr-BL" | "fr-CA" | "fr-CD" | "fr-CF" | "fr-CG" | "fr-CH" | "fr-CI" | "fr-CM" | "fr-DJ" | "fr-DZ" | "fr-GA" | "fr-GF" | "fr-GN" | "fr-GP" | "fr-GQ" | "fr-HT" | "fr-KM" | "fr-LU" | "fr-MA" | "fr-MC" | "fr-MF" | "fr-MG" | "fr-ML" | "fr-MQ" | "fr-MR" | "fr-MU" | "fr-NC" | "fr-NE" | "fr-PF" | "fr-PM" | "fr-RE" | "fr-RW" | "fr-SC" | "fr-SN" | "fr-SY" | "fr-TD" | "fr-TG" | "fr-TN" | "fr-VU" | "fr-WF" | "fr-YT" | "fr" | "fur" | "fy" | "ga-GB" | "ga" | "gd" | "gl" | "gsw-FR" | "gsw-LI" | "gsw" | "gu" | "guz" | "gv" | "ha-GH" | "ha-NE" | "ha" | "haw" | "he" | "hi" | "hr-BA" | "hr" | "hsb" | "hu" | "hy" | "ia" | "id" | "ig" | "ii" | "is" | "it-CH" | "it-SM" | "it-VA" | "it" | "ja" | "jgo" | "jmc" | "jv" | "ka" | "kab" | "kam" | "kde" | "kea" | "kgp" | "khq" | "ki" | "kk" | "kkj" | "kl" | "kln" | "km" | "kn" | "ko-KP" | "ko" | "kok" | "ks-Arab" | "ks" | "ksb" | "ksf" | "ksh" | "ku" | "kw" | "ky" | "lag" | "lb" | "lg" | "lkt" | "ln-AO" | "ln-CF" | "ln-CG" | "ln" | "lo" | "lrc-IQ" | "lrc" | "lt" | "lu" | "luo" | "luy" | "lv" | "mai" | "mas-TZ" | "mas" | "mer" | "mfe" | "mg" | "mgh" | "mgo" | "mi" | "mk" | "ml" | "mn" | "mni-Beng" | "mni" | "mr" | "ms-BN" | "ms-ID" | "ms-SG" | "ms" | "mt" | "mua" | "my" | "mzn" | "naq" | "nb-SJ" | "nb" | "nd" | "nds-NL" | "nds" | "ne-IN" | "ne" | "nl-AW" | "nl-BE" | "nl-BQ" | "nl-CW" | "nl-SR" | "nl-SX" | "nl" | "nmg" | "nn" | "nnh" | "no" | "nus" | "nyn" | "om-KE" | "om" | "or" | "os-RU" | "os" | "pa-Arab" | "pa-Guru" | "pa" | "pcm" | "pl" | "ps-PK" | "ps" | "pt-AO" | "pt-CH" | "pt-CV" | "pt-GQ" | "pt-GW" | "pt-LU" | "pt-MO" | "pt-MZ" | "pt-PT" | "pt-ST" | "pt-TL" | "pt" | "qu-BO" | "qu-EC" | "qu" | "rm" | "rn" | "ro-MD" | "ro" | "rof" | "ru-BY" | "ru-KG" | "ru-KZ" | "ru-MD" | "ru-UA" | "ru" | "rw" | "rwk" | "sa" | "sah" | "saq" | "sat-Olck" | "sat" | "sbp" | "sc" | "sd-Arab" | "sd-Deva" | "sd" | "se-FI" | "se-SE" | "se" | "seh" | "ses" | "sg" | "shi-Latn" | "shi-Tfng" | "shi" | "si" | "sk" | "sl" | "smn" | "sn" | "so-DJ" | "so-ET" | "so-KE" | "so" | "sq-MK" | "sq-XK" | "sq" | "sr-Cyrl-BA" | "sr-Cyrl-ME" | "sr-Cyrl-XK" | "sr-Cyrl" | "sr-Latn-BA" | "sr-Latn-ME" | "sr-Latn-XK" | "sr-Latn" | "sr" | "su-Latn" | "su" | "sv-AX" | "sv-FI" | "sv" | "sw-CD" | "sw-KE" | "sw-UG" | "sw" | "ta-LK" | "ta-MY" | "ta-SG" | "ta" | "te" | "teo-KE" | "teo" | "tg" | "th" | "ti-ER" | "ti" | "tk" | "to" | "tr-CY" | "tr" | "tt" | "twq" | "tzm" | "ug" | "uk" | "und" | "ur-IN" | "ur" | "uz-Arab" | "uz-Cyrl" | "uz-Latn" | "uz" | "vai-Latn" | "vai-Vaii" | "vai" | "vi" | "vun" | "wae" | "wo" | "xh" | "xog" | "yav" | "yi" | "yo-BJ" | "yo" | "yrl-CO" | "yrl-VE" | "yrl" | "yue-Hans" | "yue-Hant" | "yue" | "zgh" | "zh-Hans-HK" | "zh-Hans-MO" | "zh-Hans-SG" | "zh-Hans" | "zh-Hant-HK" | "zh-Hant-MO" | "zh-Hant" | "zh" | "zu";
|
|
19
|
-
export type DurationUnit = string | ((unitCount: number) => string);
|
|
20
|
-
export type DurationUnitName = "d" | "h" | "m" | "mo" | "ms" | "s" | "w" | "y";
|
|
21
|
-
export interface DurationUnitMeasures {
|
|
22
|
-
d: number;
|
|
23
|
-
h: number;
|
|
24
|
-
m: number;
|
|
25
|
-
mo: number;
|
|
26
|
-
ms: number;
|
|
27
|
-
s: number;
|
|
28
|
-
w: number;
|
|
29
|
-
y: number;
|
|
30
|
-
}
|
|
31
|
-
export type DurationDigitReplacements = [string, string, string, string, string, string, string, string, string, string];
|
|
32
|
-
export interface DurationLanguage {
|
|
33
|
-
_digitReplacements?: DurationDigitReplacements;
|
|
34
|
-
_hideCountIf2?: boolean;
|
|
35
|
-
_numberFirst?: boolean;
|
|
36
|
-
d: DurationUnit;
|
|
37
|
-
/**
|
|
38
|
-
* Optional character used as the decimal separator for number parsing.
|
|
39
|
-
* Defaults to ".".
|
|
40
|
-
*/
|
|
41
|
-
decimal?: string;
|
|
42
|
-
delimiter?: string;
|
|
43
|
-
future?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Optional character used as the grouping separator (e.g., thousands) for number parsing.
|
|
46
|
-
* Defaults to ",".
|
|
47
|
-
*/
|
|
48
|
-
groupSeparator?: string;
|
|
49
|
-
h: DurationUnit;
|
|
50
|
-
m: DurationUnit;
|
|
51
|
-
mo: DurationUnit;
|
|
52
|
-
ms: DurationUnit;
|
|
53
|
-
past?: string;
|
|
54
|
-
/**
|
|
55
|
-
* Optional placeholder character within numbers used during parsing.
|
|
56
|
-
* Defaults to "_".
|
|
57
|
-
*/
|
|
58
|
-
placeholderSeparator?: string;
|
|
59
|
-
s: DurationUnit;
|
|
60
|
-
/**
|
|
61
|
-
* Optional mapping of localized unit names/aliases (e.g., "saniye", "sec")
|
|
62
|
-
* to the standard unit keys (e.g., "s"). Used for parsing.
|
|
63
|
-
*/
|
|
64
|
-
unitMap?: Record<string, keyof DurationUnitMeasures>;
|
|
65
|
-
w: DurationUnit;
|
|
66
|
-
y: DurationUnit;
|
|
67
|
-
}
|
|
68
|
-
export interface DurationOptions {
|
|
69
|
-
conjunction?: string;
|
|
70
|
-
decimal?: string;
|
|
71
|
-
delimiter?: string;
|
|
72
|
-
digitReplacements?: DurationDigitReplacements;
|
|
73
|
-
fallbacks?: string[];
|
|
74
|
-
language?: DurationLanguage;
|
|
75
|
-
largest?: number;
|
|
76
|
-
maxDecimalPoints?: number;
|
|
77
|
-
round?: boolean;
|
|
78
|
-
serialComma?: boolean;
|
|
79
|
-
spacer?: string;
|
|
80
|
-
timeAdverb?: boolean;
|
|
81
|
-
unitMeasures?: DurationUnitMeasures;
|
|
82
|
-
units?: DurationUnitName[];
|
|
83
|
-
}
|
|
84
|
-
export interface DurationPiece {
|
|
85
|
-
unitCount: number;
|
|
86
|
-
unitName: DurationUnitName;
|
|
87
|
-
}
|
|
88
|
-
export type ParseByteOptions = BytesOptions;
|
|
89
|
-
export interface FormateByteOptions<ByteSize> extends BytesOptions, Omit<Intl.NumberFormatOptions, "currency" | "currencyDisplay" | "currencySign" | "style" | "unit" | "unitDisplay"> {
|
|
90
|
-
/**
|
|
91
|
-
* Specify the number of decimals to include in the output.
|
|
92
|
-
*
|
|
93
|
-
* **Note**: If `minFractionDigits` or `maxFractionDigits` are set, this option will be ignored.
|
|
94
|
-
* @default 0
|
|
95
|
-
*/
|
|
96
|
-
decimals?: number;
|
|
97
|
-
/**
|
|
98
|
-
* Whether to use the long form of the unit.
|
|
99
|
-
* @default false
|
|
100
|
-
*/
|
|
101
|
-
long?: boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Whether to include a space between the number and the unit.
|
|
104
|
-
* @default true
|
|
105
|
-
*/
|
|
106
|
-
space?: boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Specify the unit to use for the output.
|
|
109
|
-
*
|
|
110
|
-
* Uses the closest unit to the given value per default.
|
|
111
|
-
*/
|
|
112
|
-
unit?: ByteSize;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Options for the parseDuration function.
|
|
116
|
-
*/
|
|
117
|
-
export interface ParseDurationOptions {
|
|
118
|
-
/**
|
|
119
|
-
* The default unit to use if the input string is just a number.
|
|
120
|
-
* Uses standard unit keys (y, mo, w, d, h, m, s, ms).
|
|
121
|
-
* Defaults to 'ms'.
|
|
122
|
-
*/
|
|
123
|
-
defaultUnit?: keyof DurationUnitMeasures;
|
|
124
|
-
/**
|
|
125
|
-
* The language object containing localized unit names for parsing.
|
|
126
|
-
* Defaults to English.
|
|
127
|
-
*/
|
|
128
|
-
language?: DurationLanguage;
|
|
129
|
-
}
|
|
130
|
-
export {};
|