arqam 1.1.2 → 2.0.0
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/LICENSE +21 -0
- package/README.md +888 -0
- package/dist/SRI.txt +5 -0
- package/dist/arqamAR.d.mts +683 -0
- package/dist/arqamAR.mjs +2 -0
- package/dist/arqamEN.d.mts +161 -0
- package/dist/arqamEN.mjs +2 -0
- package/dist/arqamExplain.d.mts +80 -0
- package/dist/arqamExplain.mjs +2 -0
- package/dist/arqamUnits.d.mts +29 -0
- package/dist/arqamUnits.mjs +2 -0
- package/dist/arqamWordsToNumbers.d.mts +63 -0
- package/dist/arqamWordsToNumbers.mjs +2 -0
- package/package.json +111 -13
- package/numberToWordsAr.js +0 -122
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
/*! arqamAR — TypeScript declarations for dist/arqamAR.mjs. MIT licence.
|
|
2
|
+
* Copied to dist/ by tools/build_dist.py; tests/dist.test.js checks that every option, currency attribute
|
|
3
|
+
* and export of the engine is declared here.
|
|
4
|
+
* @author: Mohsen Alyafei */
|
|
5
|
+
|
|
6
|
+
/** A number: text ("1234.56", Arabic-Eastern numbers too, "-" before and "%" after allowed), a JS number or a BigInt.
|
|
7
|
+
* Pass amounts as text: a JS number keeps only about 16 significant digits. */
|
|
8
|
+
export type ArqamNumber = string | number | bigint;
|
|
9
|
+
|
|
10
|
+
/** A switch: "on" or "off" ("" is off); true and false are accepted too. */
|
|
11
|
+
export type ArqamSwitch = "on" | "off" | "" | boolean;
|
|
12
|
+
/** Arabic-Eastern (١٢٣) "on" or "eastern"; Arabic-Western (123) "off" or "western". Default: by the locale's region, else Arabic-Western. */
|
|
13
|
+
export type ArqamDigits = ArqamSwitch | "eastern" | "western";
|
|
14
|
+
|
|
15
|
+
/** The tashkeel values: the readable names and the short codes */
|
|
16
|
+
export type ArqamTashkeelValue = "alif" | "none" | "fatha" | "tanween" | "endings" | "full" | "" | "a" | "n" | "h" | "t" | "p" | "f";
|
|
17
|
+
/** arqamAR.optionNames: for each coded option, its readable names and the short code each one stands for */
|
|
18
|
+
export interface ArqamOptionNames {
|
|
19
|
+
tashkeel : {none: "n"; alif: "a"; fatha: "h"; tanween: "t"; endings: "p"; full: "f"};
|
|
20
|
+
ierab : {raf: "r"; nasb: "n"; jarr: "j"};
|
|
21
|
+
legal : {none: "n"; auto: "a"; full: "f"};
|
|
22
|
+
numSymbol: {code: "i"; symbol: "s"; latin: "l"; name: "c"; none: "sub"; sign: "g"; english: "l"; native: "s"};
|
|
23
|
+
decFormat: {auto: ""; words: "w"; figures: "n"; digits: "sw"; "words-words": "ww"; "words-figures": "wn";
|
|
24
|
+
"figures-words": "nw"; "figures-figures": "nn"; decimal: "d"; slash: "/"};
|
|
25
|
+
ordinal : {masculine: "m"; feminine: "f"};
|
|
26
|
+
}
|
|
27
|
+
/** Options for config() and for one call of toWords() / toParts(). Unknown names and bad values throw a TypeError. */
|
|
28
|
+
export interface ArqamOptions {
|
|
29
|
+
/** "" for numbers, or a currency code (built in, or added with registerCurrency); the name Intl gives it. */
|
|
30
|
+
currency?: string;
|
|
31
|
+
/** "alif"/"a"/"": tanween on an alif ending only (the default: ريالًا) · "none"/"n": no marks · "fatha"/"h": every fatha tanween ·
|
|
32
|
+
* "tanween"/"t": all three tanween · "endings"/"p": tanween and the last vowel of each word · "full"/"f": full tashkeel.
|
|
33
|
+
* The name or the short code, in any letter case */
|
|
34
|
+
tashkeel?: ArqamTashkeelValue;
|
|
35
|
+
/** "raf"/"r": nominative (default) · "nasb"/"n": accusative · "jarr"/"j": genitive · "": the default */
|
|
36
|
+
ierab?: "raf" | "nasb" | "jarr" | "r" | "n" | "j" | "";
|
|
37
|
+
/** Legal form (ثلاثمائة ألف وألفان): "none"/"" (default) · "auto"/"a": hundreds followed by 1 or 2 only ·
|
|
38
|
+
* "full"/"f": every group with hundreds */
|
|
39
|
+
/** The legal form: "auto" ("" or not given, the default) «مائة ألف وألف», "none" «مائة وألف», "full" every group */
|
|
40
|
+
legal?: "none" | "auto" | "full" | "" | "a" | "f" | "n";
|
|
41
|
+
/** مليار/تريليون (arabic, default) · بليون/تريليون (short) · long scale */
|
|
42
|
+
scale?: "arabic" | "short" | "long" | "a" | "s" | "l";
|
|
43
|
+
/** The figure in brackets after (end) or before (start) the words, or the fraction in brackets (decimals) */
|
|
44
|
+
brackets?: "" | "end" | "start" | "decimals" | "e" | "s" | "d";
|
|
45
|
+
/** The bracket characters, e.g. "[]" or "«»" (default "()") */
|
|
46
|
+
bracketsType?: string;
|
|
47
|
+
/** Label in the brackets: "code"/"i": the ISO code, QAR (default) · "symbol"/"s": ر.ق. · "latin"/"l": QR ·
|
|
48
|
+
* "name"/"c": the currency's name · "none"/"sub": the figure only · any other text: a symbol of your own */
|
|
49
|
+
/** In the brackets: ISO code (default) · "english"/"latin": QR, else Native, else the code · "native"/"symbol": ر.ق.,
|
|
50
|
+
* else English, else the code · "sign": the Symbol, one Unicode character ( SAR, € EUR, $ USD), else Native, else the code ·
|
|
51
|
+
* name · none · or a symbol of your own */
|
|
52
|
+
numSymbol?: "code" | "english" | "native" | "symbol" | "latin" | "name" | "none" | "sign" | "i" | "s" | "l" | "c" | "sub" | "g" | (string & {});
|
|
53
|
+
/** The fraction's form: "auto"/"" (default: currencies their minor unit, numbers words-words) ·
|
|
54
|
+
* "words"/"w" · "figures"/"n" · "digits"/"sw" · "words-words"/"ww" · "words-figures"/"wn" · "figures-words"/"nw" ·
|
|
55
|
+
* "figures-figures"/"nn" · "decimal"/"d" · "slash"/"/" */
|
|
56
|
+
decFormat?: "auto" | "words" | "figures" | "digits" | "words-words" | "words-figures" | "figures-words" | "figures-figures" |
|
|
57
|
+
"decimal" | "slash" | "" | "w" | "n" | "sw" | "ww" | "wn" | "nw" | "nn" | "d" | "/";
|
|
58
|
+
/** Decimal places kept in numbers mode (cut, or rounded with rounding:"on"); "" (the default) keeps every decimal */
|
|
59
|
+
decRound?: number | string;
|
|
60
|
+
/** Separators in the brackets only: a character, or a locale tag such as "fr" */
|
|
61
|
+
sepDecimal?: string;
|
|
62
|
+
sepThousands?: string;
|
|
63
|
+
/** Words before and after, e.g. فقط … لا غير */
|
|
64
|
+
prefix?: string;
|
|
65
|
+
suffix?: string;
|
|
66
|
+
/** Returned for a number that cannot be written (default ""); see strict */
|
|
67
|
+
isNaN?: unknown;
|
|
68
|
+
/** The words of a zero amount instead of «صفر ريال قطري», e.g. "لا شيء" (default "": صفر); prefix and suffix are kept */
|
|
69
|
+
zeroWords?: string;
|
|
70
|
+
/** The language of the error messages: "" or "en" English (the default), "ar" Arabic; the call's name stays as it is. The English message is kept in the error's property english */
|
|
71
|
+
errorLanguage?: "" | "en" | "ar";
|
|
72
|
+
/** Figures for groups, words for scale names: مليون، و234 ألفا */
|
|
73
|
+
compact?: ArqamSwitch;
|
|
74
|
+
/** Tanween on the letter before the final alif (ريالاً) */
|
|
75
|
+
tanweenAlif?: ArqamSwitch;
|
|
76
|
+
/** مائة (on, default) or مئة (off) */
|
|
77
|
+
miah?: ArqamSwitch;
|
|
78
|
+
/** ثلاث مائة written apart */
|
|
79
|
+
miahSplit?: ArqamSwitch;
|
|
80
|
+
/** The Arabic comma before و between groups (default on) */
|
|
81
|
+
comma?: ArqamSwitch;
|
|
82
|
+
/** صفر before a fraction of one */
|
|
83
|
+
addZero?: ArqamSwitch;
|
|
84
|
+
/** Arabic-Eastern numbers (٠١٢٣٤٥٦٧٨٩) in the brackets instead of Arabic-Western numbers (0123456789). With no separator
|
|
85
|
+
* given they use the Arabic separators: the Arabic decimal separator ٫ (U+066B), used in formal and typeset
|
|
86
|
+
* Arabic numbers, e.g. ٣٫١; the Arabic thousands separator ٬ (U+066C), which groups large numbers into thousands,
|
|
87
|
+
* e.g. ١٬٠٠٠٬٠٠٠ */
|
|
88
|
+
arabicNumbers?: ArqamDigits;
|
|
89
|
+
/** The word جزء in fractions (default on) */
|
|
90
|
+
decJuz?: ArqamSwitch;
|
|
91
|
+
/** فاصلة instead of و before the fraction */
|
|
92
|
+
decFaslah?: ArqamSwitch;
|
|
93
|
+
/** The whole part only */
|
|
94
|
+
decIgnore?: ArqamSwitch;
|
|
95
|
+
/** الـ in fractions: من المائة (on, default) or من مائة */
|
|
96
|
+
decAL?: ArqamSwitch;
|
|
97
|
+
/** ريال instead of ريال قطري (a qualifier is never dropped) */
|
|
98
|
+
ignoreCountry?: ArqamSwitch;
|
|
99
|
+
/** The figure in brackets shows the currency's places: 1,234.00 (default on) */
|
|
100
|
+
currDecForce?: ArqamSwitch;
|
|
101
|
+
/** Colour markers in the words (|p punctuation, |c currency names, |f fraction, | groups) */
|
|
102
|
+
split?: ArqamSwitch;
|
|
103
|
+
/** Round extra decimal digits half up instead of cutting them */
|
|
104
|
+
rounding?: ArqamSwitch;
|
|
105
|
+
/** Throw a TypeError or RangeError that says why a number cannot be written, instead of returning isNaN */
|
|
106
|
+
strict?: ArqamSwitch;
|
|
107
|
+
/** Read the number as a percentage: خمسة وعشرون بالمائة ("25%" as input does the same) */
|
|
108
|
+
percent?: ArqamSwitch;
|
|
109
|
+
/** The ordinal, masculine or feminine, of a whole number from 1 to 999,999: الحادي عشر / الحادية عشرة */
|
|
110
|
+
ordinal?: "masculine" | "feminine" | "" | "m" | "f";
|
|
111
|
+
/** "off": the ordinal without الـ: أول، ثانٍ، حادٍ وعشرون، خامس عشر; default "on" */
|
|
112
|
+
ordinalDefinite?: "on" | "off" | boolean;
|
|
113
|
+
/** «واحد/اثنان» after the counted noun: "" (default) none (ريال قطري، ريالان قطريان) but in the legal form and the
|
|
114
|
+
* cheque form (فقط … لا غير), where the number is said twice · "on" always · "off" never */
|
|
115
|
+
emphasisOneTwo?: "" | "on" | "off" | boolean;
|
|
116
|
+
/** An approximate quantity: "about" قرابةَ ألفِ ريالٍ · "over" ما يزيد على · "under" أقلّ من · "atLeast" ما لا يقل عن ·
|
|
117
|
+
* "atMost" ما لا يزيد على (the number in the genitive after them) · "few" بضعةُ آلافٍ (3-9, whole numbers) ·
|
|
118
|
+
* "plus" نيّفٌ وعشرون، مائةُ ريالٍ ونيّفٌ (1-9, whole numbers); "" or "none": the exact number (default) */
|
|
119
|
+
approx?: "" | "none" | "about" | "over" | "under" | "atLeast" | "atMost" | "few" | "plus" | "atleast" | "atmost";
|
|
120
|
+
/** The word of approx "about": "qurabah" قرابة (default), "nahw" نحو, "zuhaa" زهاء, "hawali" حوالَيْ */
|
|
121
|
+
approxWord?: "" | "qurabah" | "nahw" | "zuhaa" | "hawali";
|
|
122
|
+
/** With approx, round first to this many significant digits (987450 with 1: قرابة مليون); "" as given */
|
|
123
|
+
approxRound?: number | string;
|
|
124
|
+
/** "small": the smallest part first, as in classical Arabic: خمسون ومائتان، وألفُ ريالٍ; "" or "large": largest first */
|
|
125
|
+
wordOrder?: "" | "large" | "small";
|
|
126
|
+
/** The region, e.g. "ar-QA": its currency (toWords with no code), month names, digits, separators
|
|
127
|
+
* (1.234,5 in ar-LY, ar-TN, ar-DZ, ar-MA) and time zone, for every method; options given in the call or later win.
|
|
128
|
+
* The 22 Arab League locales are known (arqamAR.regions); "ar" with another country keeps only its currency in
|
|
129
|
+
* NumberFormat. */
|
|
130
|
+
locale?: string;
|
|
131
|
+
/** The clock of an exact moment (ISO with Z or an offset, or a Date): "" (the locale's zone, else as written),
|
|
132
|
+
* "asWritten", "local" (the computer's) or an IANA name such as "Asia/Qatar"; an unknown name is a RangeError */
|
|
133
|
+
timeZone?: string;
|
|
134
|
+
/** How the zone is named after the time: "" or "city" (بتوقيت الدوحة) · "country" (بتوقيت قطر) · "offset"
|
|
135
|
+
* (بتوقيت غرينتش +3) · "both" (بتوقيت الدوحة (غرينتش +3)) · "off" */
|
|
136
|
+
/** The offset carries a direction mark before its sign: LRM (U+200E), or ALM (U+061C) with Arabic-Eastern numbers. */
|
|
137
|
+
zoneName?: "" | "city" | "country" | "offset" | "both" | "off";
|
|
138
|
+
/** Names for a one-off custom currency (registerCurrency is the better way) */
|
|
139
|
+
currDecimal?: number | string;
|
|
140
|
+
majorSingle?: string; majorSingleC?: string; majorPlural?: string; majorPluralC?: string;
|
|
141
|
+
minorSingle?: string; minorSingleC?: string; minorPlural?: string; minorPluralC?: string;
|
|
142
|
+
majorSingleT?: string; majorSingleCT?: string; majorPluralT?: string; majorPluralCT?: string;
|
|
143
|
+
minorSingleT?: string; minorSingleCT?: string; minorPluralT?: string; minorPluralCT?: string;
|
|
144
|
+
/** 1: feminine. With a code: the custom currency's gender; without one: numbers for a feminine noun (ست وعشرون) */
|
|
145
|
+
majorGender?: 0 | 1 | "0" | "1" | boolean | "";
|
|
146
|
+
minorGender?: 0 | 1 | "0" | "1" | boolean | "";
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Attributes for registerCurrency(). A new code needs majorSingle and majorPlural; a singular and its plural go together. */
|
|
150
|
+
export interface ArqamCurrencyAttributes {
|
|
151
|
+
/** Decimal places, 0 to 18 */
|
|
152
|
+
currDecimal?: number | string;
|
|
153
|
+
majorSingle?: string; majorPlural?: string; majorSingleC?: string; majorPluralC?: string;
|
|
154
|
+
minorSingle?: string; minorPlural?: string; minorSingleC?: string; minorPluralC?: string;
|
|
155
|
+
/** The same names with full tashkeel, used with tashkeel:"f" */
|
|
156
|
+
majorSingleT?: string; majorPluralT?: string; majorSingleCT?: string; majorPluralCT?: string;
|
|
157
|
+
minorSingleT?: string; minorPluralT?: string; minorSingleCT?: string; minorPluralCT?: string;
|
|
158
|
+
/** 0 masculine (default), 1 feminine */
|
|
159
|
+
majorGender?: 0 | 1 | "0" | "1" | boolean;
|
|
160
|
+
minorGender?: 0 | 1 | "0" | "1" | boolean;
|
|
161
|
+
symbolLatin?: string;
|
|
162
|
+
symbolNative?: string;
|
|
163
|
+
/** The currency's Symbol, one Unicode character, for numSymbol "sign", e.g. "\u20C1"; "" removes it */
|
|
164
|
+
symbol?: string;
|
|
165
|
+
/** The same as symbol (an older name) */
|
|
166
|
+
sign?: string;
|
|
167
|
+
/** Decimals written as given (crypto); with currDecimal 0: any number of decimals, read as typed */
|
|
168
|
+
openDecimals?: boolean;
|
|
169
|
+
/** A fixed phrase after the noun and its number word, never declined: كيلومتر واحد في الساعة */
|
|
170
|
+
qualifier?: string;
|
|
171
|
+
qualifierT?: string;
|
|
172
|
+
/** The second term of an iḍāfa, right after the noun: ملعقةُ شايٍ واحدةٌ، ملعقتا شايٍ */
|
|
173
|
+
idafa?: string;
|
|
174
|
+
idafaT?: string;
|
|
175
|
+
/** The place name; the adjective (majorSingleC) is made from it with nisba() unless given: قطر -> قطري */
|
|
176
|
+
country?: string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** ToParts(): the words in their parts. Without colours,
|
|
180
|
+
* text = [prefix, [sign, whole + fraction] joined by " ", suffix] joined by " ", with brackets before or after. */
|
|
181
|
+
export interface ArqamParts {
|
|
182
|
+
/** The same words as toWords() */
|
|
183
|
+
text: string;
|
|
184
|
+
/** false when the number could not be written (text is then the isNaN option) */
|
|
185
|
+
valid: boolean;
|
|
186
|
+
negative: boolean;
|
|
187
|
+
percent: boolean;
|
|
188
|
+
/** "m" or "f" for an ordinal, else "" */
|
|
189
|
+
ordinal: "" | "m" | "f";
|
|
190
|
+
prefix: string;
|
|
191
|
+
/** The negative word (سالب) as written, or "" */
|
|
192
|
+
sign: string;
|
|
193
|
+
/** The whole part with its currency name; all the words of a percentage or an ordinal */
|
|
194
|
+
whole: string;
|
|
195
|
+
/** The fraction with its joiner, e.g. "، وخمسون درهما" */
|
|
196
|
+
fraction: string;
|
|
197
|
+
suffix: string;
|
|
198
|
+
/** The brackets as written, e.g. "(-1,250.50 QAR)", or "" */
|
|
199
|
+
brackets: string;
|
|
200
|
+
/** The brackets' content, e.g. "-1,250.50 QAR", or "" */
|
|
201
|
+
figure: string;
|
|
202
|
+
/** The approximate words before the number (قرابة، ما يزيد على), or "" */
|
|
203
|
+
approx?: string;
|
|
204
|
+
/** «ونيّف» after the number, or "" */
|
|
205
|
+
approxTrail?: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** A date for toDate(): text ("18/11/2026", "2026-11-18", "2026-11-18T10:30", "18 نوفمبر 2026", "November 18, 2026",
|
|
209
|
+
* Arabic-Eastern numbers, the separator ؍) or a Date (its own calendar day). With input:"h" text is a Hijri date ("8/6/1448"). */
|
|
210
|
+
export type ArqamDate = string | Date;
|
|
211
|
+
/** A date with a time for toDateTime(): ISO text ("2026-11-24T06:15:00Z", "2026-11-24T09:15:00+03:00", the compact
|
|
212
|
+
* "20261124T061500Z", or with no zone: as written) or a Date. */
|
|
213
|
+
export type ArqamDateTime = string | Date;
|
|
214
|
+
|
|
215
|
+
/** Options for toDate(). Unknown names and bad values throw a TypeError. */
|
|
216
|
+
export interface ArqamDateOptions {
|
|
217
|
+
/** The region (its month names; with timeZone, the day of a moment in its zone) */
|
|
218
|
+
locale?: string;
|
|
219
|
+
/** An exact moment (ISO with Z or an offset, or a Date) is written as its day in this zone */
|
|
220
|
+
timeZone?: string;
|
|
221
|
+
/** G: Gregorian · h: Hijri (Umm al-Qura) · b: both, joined by «الموافق». Default: the calendar the date was read in: Gregorian, or Hijri for a Hijri date. */
|
|
222
|
+
calendar?: "" | "g" | "h" | "b" | "gregorian" | "hijri" | "both";
|
|
223
|
+
/** The calendar of the date given: g or h (Hijri, e.g. "8/6/1448", "8 جمادى الآخرة 1448"). Not needed when the year is followed by «هـ», «هجري», AH (Hijri) or «م», «ميلادي», AD, CE (Gregorian), or the month is a Hijri month by name; otherwise Gregorian. A mark that contradicts it is an error. */
|
|
224
|
+
input?: "" | "g" | "h" | "gregorian" | "hijri";
|
|
225
|
+
/** words: الثامن عشر من شهر نوفمبر لعام ألفين وستة وعشرين للميلاد (default) · ordinal: … سنة 2026 ميلادية · compact: 18 نوفمبر 2026م */
|
|
226
|
+
style?: "" | "words" | "ordinal" | "compact";
|
|
227
|
+
/** Gregorian month names: gulf يناير (default) · levant كانون الثاني · both يناير/كانون الثاني · maghreb جانفي · morocco يناير/غشت/دجنبر */
|
|
228
|
+
months?: "" | "gulf" | "levant" | "both" | "maghreb" | "morocco";
|
|
229
|
+
/** The word before the year: liaam لعام (words) · sana سنة (ordinal) · aam عام · none (compact) */
|
|
230
|
+
year?: "" | "none" | "liaam" | "sana" | "aam";
|
|
231
|
+
/** long: للميلاد / ميلادية / ميلادي, agreeing with the year word · short: م / هـ (compact) · none */
|
|
232
|
+
era?: "" | "long" | "short" | "none";
|
|
233
|
+
/** غرة instead of the first day */
|
|
234
|
+
gora?: ArqamSwitch;
|
|
235
|
+
/** dmy (default): 05/06/2026 is 5 June · mdy: month/day/year */
|
|
236
|
+
order?: "" | "dmy" | "mdy";
|
|
237
|
+
/** The case of the date's day, given in the call (a standing config() ierab does not apply): raf السادسُ والعشرون
|
|
238
|
+
* (default) · nasb السادسَ والعشرين (an adverb of time) · jarr السادسِ والعشرين (after في، بتاريخ …) */
|
|
239
|
+
ierab?: ArqamOptions["ierab"];
|
|
240
|
+
/** Shared with the number options */
|
|
241
|
+
tashkeel?: ArqamOptions["tashkeel"];
|
|
242
|
+
arabicNumbers?: ArqamDigits;
|
|
243
|
+
miah?: ArqamSwitch;
|
|
244
|
+
strict?: ArqamSwitch;
|
|
245
|
+
isNaN?: unknown;
|
|
246
|
+
/** The year in words smallest part first: سنة ست وعشرين وألفين */
|
|
247
|
+
wordOrder?: ArqamOptions["wordOrder"];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** A time for toTime(): text ("15:45", "3:15 pm", "3:15 م", "07:05:30", Arabic-Eastern numbers) or a Date (its
|
|
251
|
+
* local time). A duration may have more than 23 hours (up to 999). */
|
|
252
|
+
export type ArqamTime = string | Date;
|
|
253
|
+
|
|
254
|
+
/** Options for toTime(). Unknown names and bad values throw a TypeError. */
|
|
255
|
+
export interface ArqamTimeOptions {
|
|
256
|
+
/** common: الساعة الثالثة وخمس وأربعون دقيقة عصرًا (default) · exact: الساعة الثالثة وخمس وأربعون دقيقة مساءً ·
|
|
257
|
+
* h24: الساعة الخامسة عشرة وخمس وأربعون دقيقة · duration: 2:30 -> ساعتان ونصف */
|
|
258
|
+
timeStyle?: "" | "common" | "exact" | "h24" | "duration";
|
|
259
|
+
/** The part of the day (default on). 0:01-0:59 is «بعد منتصف الليل» in every clock style. common: ليلًا، فجرًا،
|
|
260
|
+
* صباحًا، ظهرًا، عصرًا، مساءً · exact: صباحًا (1:00-11:59), ظهرًا (12:00), مساءً (12:01-23:59) · h24: none */
|
|
261
|
+
timePeriod?: ArqamSwitch;
|
|
262
|
+
/** The hour's parts in "common" only: الساعة الرابعة إلا الربع عصرًا (default off: the minutes are counted).
|
|
263
|
+
* With another timeStyle it throws a TypeError. */
|
|
264
|
+
timeParts?: ArqamSwitch;
|
|
265
|
+
/** The seconds when they are not 00 (default on) */
|
|
266
|
+
timeSeconds?: ArqamSwitch;
|
|
267
|
+
/** The case of the time, given in the call: raf الساعةُ العاشرةُ (default) · nasb الساعةَ العاشرةَ ·
|
|
268
|
+
* jarr الساعةِ العاشرةِ (في الساعةِ …); a duration: ساعتان ونصف · ساعتين ونصفًا · ساعتين ونصفٍ */
|
|
269
|
+
ierab?: ArqamOptions["ierab"];
|
|
270
|
+
/** «الساعة» first (default on) */
|
|
271
|
+
timeWord?: ArqamSwitch;
|
|
272
|
+
/** Shared with the number options */
|
|
273
|
+
tashkeel?: ArqamOptions["tashkeel"];
|
|
274
|
+
tanweenAlif?: ArqamSwitch;
|
|
275
|
+
miah?: ArqamSwitch;
|
|
276
|
+
strict?: ArqamSwitch;
|
|
277
|
+
isNaN?: unknown;
|
|
278
|
+
/** Arabic-Eastern numbers in the zone's offset (غرينتش +٣) */
|
|
279
|
+
arabicNumbers?: ArqamDigits;
|
|
280
|
+
/** The region, the zone of a moment and how it is named (see ArqamOptions) */
|
|
281
|
+
locale?: string;
|
|
282
|
+
timeZone?: string;
|
|
283
|
+
zoneName?: ArqamOptions["zoneName"];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** Options of toDateTime(): those of toDate and of toTime (not timeStyle "duration"). */
|
|
287
|
+
export interface ArqamDateTimeOptions extends Omit<ArqamDateOptions, "locale" | "timeZone">, Omit<ArqamTimeOptions, "tashkeel" | "miah" | "strict" | "isNaN" | "timeStyle"> {
|
|
288
|
+
timeStyle?: "" | "common" | "exact" | "h24";
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** One of the 22 Arab locales in arqamAR.regions */
|
|
292
|
+
export interface ArqamRegion {
|
|
293
|
+
timeZone: string; currency: string; months: "gulf" | "levant" | "maghreb" | "morocco";
|
|
294
|
+
digits: "arab" | "latn"; separators: string; city: string; cityT: string; country: string; countryT: string;
|
|
295
|
+
}
|
|
296
|
+
/** One named zone in arqamAR.timeZones (own: the name given with registerTimeZone) */
|
|
297
|
+
export interface ArqamZoneName {
|
|
298
|
+
city?: string; cityT?: string; country?: string; countryT?: string; hub?: boolean; own?: string;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** A fraction for toFraction(): text ("3/4", "3 1/2", "3½", "¾", "11/4", "٣/٤", a whole number "5" or a decimal "2.5")
|
|
302
|
+
* or a JS number. */
|
|
303
|
+
export type ArqamFraction = string | number;
|
|
304
|
+
|
|
305
|
+
/** Options for toFraction(). Unknown names and bad values throw a TypeError. */
|
|
306
|
+
export interface ArqamFractionOptions {
|
|
307
|
+
/** named: ثلاثة أرباع (default; halves to tenths, else «أجزاء من») · parts: ثلاثة أجزاء من أربعة · math: ثلاثة على أربعة */
|
|
308
|
+
fractionForm?: "" | "named" | "parts" | "math";
|
|
309
|
+
/** An improper fraction as a whole number and a fraction: 11/4 -> اثنان وثلاثة أرباع (default on; off: أحد عشر ربعًا) */
|
|
310
|
+
fractionMixed?: ArqamSwitch;
|
|
311
|
+
/** Simplify first: 2/4 -> نصف (default off; a decimal is always simplified) */
|
|
312
|
+
fractionSimplify?: ArqamSwitch;
|
|
313
|
+
/** With a currency or unit, «واحد/اثنان» after the noun: default off («كيلومتر ونصف»); on: «كيلومتر واحد ونصف» */
|
|
314
|
+
emphasisOneTwo?: ArqamSwitch;
|
|
315
|
+
/** The case of the fraction, given in the call: raf ثلثٌ (default) · nasb ثلثًا، ثلثَ ريالٍ · jarr ثلثٍ، ثلثَيْ ريالٍ */
|
|
316
|
+
ierab?: ArqamOptions["ierab"];
|
|
317
|
+
/** With a code: minor (default): the minor unit when the amount is exact (2 1/2 QAR -> ريالان قطريان اثنان، وخمسون درهمًا) ·
|
|
318
|
+
* named: the fraction word (ريالان قطريان اثنان ونصف، نصف ريال قطري) */
|
|
319
|
+
fractionUnit?: "" | "minor" | "named";
|
|
320
|
+
/** Shared with the number options */
|
|
321
|
+
tashkeel?: ArqamOptions["tashkeel"];
|
|
322
|
+
tanweenAlif?: ArqamSwitch;
|
|
323
|
+
currency?: string;
|
|
324
|
+
miah?: ArqamSwitch;
|
|
325
|
+
strict?: ArqamSwitch;
|
|
326
|
+
isNaN?: unknown;
|
|
327
|
+
ignoreCountry?: ArqamSwitch;
|
|
328
|
+
comma?: ArqamSwitch;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** The styles of arqamAR.NumberFormat. decimal, percent, currency and unit as in Intl; ordinal,
|
|
332
|
+
* fraction, time and date are Arqam's own (toWords with ordinal, toFraction, toTime, toDate). */
|
|
333
|
+
export type ArqamNumberFormatStyle = "decimal" | "percent" | "currency" | "unit" | "ordinal" | "fraction" | "time" | "date" | "dateTime";
|
|
334
|
+
|
|
335
|
+
/** Options of arqamAR.NumberFormat: the Intl names below and every Arqam option (Arqam's name wins when both are
|
|
336
|
+
* given). The options of toFraction (fraction...), toTime (time...) and toDate (calendar, months, year, era, order,
|
|
337
|
+
* gora, input; and dateForm for toDate's style) go with their style only. Intl options for figures (useGrouping,
|
|
338
|
+
* notation, minimumFractionDigits …) are refused with a RangeError. */
|
|
339
|
+
export interface ArqamNumberFormatOptions extends Omit<ArqamOptions, "locale">,
|
|
340
|
+
Omit<ArqamTimeOptions, keyof ArqamOptions>, Omit<ArqamFractionOptions, keyof ArqamOptions>, Omit<ArqamDateOptions, "style" | "calendar" | keyof ArqamOptions> {
|
|
341
|
+
/** default "decimal" */
|
|
342
|
+
style?: ArqamNumberFormatStyle;
|
|
343
|
+
/** style "currency" (and "fraction", for an amount): an ISO code ("QAR"); default: the currency of the locale's country (ar-QA -> QAR) */
|
|
344
|
+
currency?: string;
|
|
345
|
+
/** style "currency": the figure's sign in brackets: code · symbol and narrowSymbol (the Symbol, $) · name · sign (= symbol) ·
|
|
346
|
+
* native (ر.ق.) · english (QR). Arqam: numSymbol */
|
|
347
|
+
currencyDisplay?: "code" | "symbol" | "narrowSymbol" | "name" | "sign" | "native" | "english";
|
|
348
|
+
/** style "unit" (with the units add-on): an Intl name ("kilometer", "kilometer-per-hour"), an Arqam key ("A05") or
|
|
349
|
+
* the Arabic name ("كيلومتر") */
|
|
350
|
+
unit?: string;
|
|
351
|
+
/** style "unit": "long" only (the unit's name in words) */
|
|
352
|
+
unitDisplay?: "long";
|
|
353
|
+
/** "arab": Arabic-Eastern numbers, as -u-nu-arab in the locale; "latn": Western. Arqam: arabicNumbers */
|
|
354
|
+
numberingSystem?: "arab" | "latn";
|
|
355
|
+
/** style "date": gregory · islamic / islamic-umalqura (Umm al-Qura) · or Arqam's gregorian, hijri, both (g, h, b) */
|
|
356
|
+
calendar?: "gregory" | "islamic" | "islamic-umalqura" | "" | "g" | "h" | "b" | "gregorian" | "hijri" | "both";
|
|
357
|
+
/** style "date": toDate's style: words (default), ordinal, compact */
|
|
358
|
+
dateForm?: "" | "words" | "ordinal" | "compact";
|
|
359
|
+
/** styles decimal, percent, currency and unit: the places of the number (0-100). Default, as Intl: 3 for a decimal
|
|
360
|
+
* and a unit, 0 for a percentage; a currency rounds to its minor unit */
|
|
361
|
+
maximumFractionDigits?: number;
|
|
362
|
+
/** halfExpand (round half up, the default, as Intl) or trunc (cut) */
|
|
363
|
+
roundingMode?: "halfExpand" | "trunc";
|
|
364
|
+
/** auto / negative: «سالب» before a negative number (default) · always: «موجب» before a number that is not negative ·
|
|
365
|
+
* exceptZero: «موجب» before a number above zero · never: no sign */
|
|
366
|
+
signDisplay?: "auto" | "always" | "exceptZero" | "negative" | "never";
|
|
367
|
+
/** taken for Intl's sake; there is one locale to choose */
|
|
368
|
+
localeMatcher?: "lookup" | "best fit";
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** What resolvedOptions() gives: the locale, the style and the options in force (readable names: tashkeel "full"). */
|
|
372
|
+
export interface ArqamResolvedOptions extends ArqamNumberFormatOptions {
|
|
373
|
+
locale: string;
|
|
374
|
+
style: ArqamNumberFormatStyle;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** The type of a part of the words. The Intl names where Intl has one; Arqam's own: minorCurrency, minorUnit,
|
|
378
|
+
* denominator («جزءا من المائة»), ordinal, prefix, suffix and figure. Scale words stay in integer. */
|
|
379
|
+
export type ArqamPartType = "literal" | "integer" | "fraction" | "currency" | "minorCurrency" | "unit" | "minorUnit" |
|
|
380
|
+
"denominator" | "decimal" | "percentSign" | "minusSign" | "ordinal" | "prefix" | "suffix" | "figure" | "approx" |
|
|
381
|
+
"day" | "month" | "year" | "era" | "hour" | "minute" | "second" | "dayPeriod" | "timeZone";
|
|
382
|
+
|
|
383
|
+
/** A part of the figure in brackets, as Intl cuts figures: (-1,250.50 QAR). */
|
|
384
|
+
export interface ArqamFigurePart {
|
|
385
|
+
type: "literal" | "minusSign" | "integer" | "group" | "decimal" | "fraction" | "percentSign" | "currency" | "unit";
|
|
386
|
+
value: string;
|
|
387
|
+
/** True when the currency part is a new Unicode sign (give it a font that has the sign) */
|
|
388
|
+
sign?: true;
|
|
389
|
+
/** The sign's code point, e.g. "U+20C1" */
|
|
390
|
+
codepoint?: string;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** One part of formatToParts(). Joining every value gives format() exactly. */
|
|
394
|
+
export interface ArqamPart {
|
|
395
|
+
type: ArqamPartType;
|
|
396
|
+
value: string;
|
|
397
|
+
/** only on a part of type "figure": the figure cut as Intl would cut it */
|
|
398
|
+
parts?: ArqamFigurePart[];
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/** One part of formatRangeToParts(): which value it belongs to, as in Intl. */
|
|
402
|
+
export interface ArqamRangePart extends ArqamPart {
|
|
403
|
+
source: "startRange" | "endRange" | "shared";
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/** A formatter: format() and formatToParts() are bound, so list.map(nf.format) works; the object is frozen. */
|
|
407
|
+
export interface ArqamNumberFormatInstance {
|
|
408
|
+
format(x: ArqamNumber | ArqamTime | ArqamFraction | ArqamDate): string;
|
|
409
|
+
format(x: Array<ArqamNumber | ArqamTime | ArqamFraction | ArqamDate>): string[];
|
|
410
|
+
/** The words of format(x) as a list of {type, value}, in order; a value that cannot be written gives [] (or the isNaN text) */
|
|
411
|
+
formatToParts(x: ArqamNumber | ArqamTime | ArqamFraction | ArqamDate): ArqamPart[];
|
|
412
|
+
formatToParts(x: Array<ArqamNumber | ArqamTime | ArqamFraction | ArqamDate>): ArqamPart[][];
|
|
413
|
+
/** «من A إلى B», both values in the genitive; equal values give one value; a start after the end is a RangeError */
|
|
414
|
+
formatRange(start: ArqamNumber | ArqamTime | ArqamFraction | ArqamDate, end: ArqamNumber | ArqamTime | ArqamFraction | ArqamDate): string;
|
|
415
|
+
/** How the formatter writes x: the method, the value it passes and the options (for arqamExplain's explain.range) */
|
|
416
|
+
plan(x: ArqamNumber | ArqamTime | ArqamFraction | ArqamDate): {method: "toWords" | "toTime" | "toFraction" | "toDate" | "toDateTime"; value: unknown; options: Record<string, unknown>};
|
|
417
|
+
/** The parts of formatRange(), each with source "startRange", "endRange" or "shared" */
|
|
418
|
+
formatRangeToParts(start: ArqamNumber | ArqamTime | ArqamFraction | ArqamDate, end: ArqamNumber | ArqamTime | ArqamFraction | ArqamDate): ArqamRangePart[];
|
|
419
|
+
resolvedOptions(): ArqamResolvedOptions;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** arqamAR.NumberFormat: with or without new; the locale is optional ("ar", or the standing option locale), and
|
|
423
|
+
* an object first is the options: NumberFormat({tashkeel: "full"}). Only Arabic locales ("ar", "ar-QA", "ar-SA-u-nu-arab"). */
|
|
424
|
+
export interface ArqamNumberFormatConstructor {
|
|
425
|
+
new (locales?: string | string[], options?: ArqamNumberFormatOptions): ArqamNumberFormatInstance;
|
|
426
|
+
new (options?: ArqamNumberFormatOptions): ArqamNumberFormatInstance;
|
|
427
|
+
(locales?: string | string[], options?: ArqamNumberFormatOptions): ArqamNumberFormatInstance;
|
|
428
|
+
(options?: ArqamNumberFormatOptions): ArqamNumberFormatInstance;
|
|
429
|
+
/** The Arabic locales of the list, in their canonical form */
|
|
430
|
+
supportedLocalesOf(locales?: string | string[]): string[];
|
|
431
|
+
readonly styles: ArqamNumberFormatStyle[];
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/** The currency table: code -> its row of up to 24 slots (see the developer manual, §2.5). */
|
|
435
|
+
export type ArqamCurrencyTable = Record<string, unknown[]>;
|
|
436
|
+
|
|
437
|
+
/** Nisba() options: feminine gives قطرية، كورية شمالية. */
|
|
438
|
+
export interface ArqamNisbaOptions {
|
|
439
|
+
feminine?: boolean;
|
|
440
|
+
}
|
|
441
|
+
/** RemoveTashkeel() options: "on" also removes tatweel ـ / the hamza from the alif only, آ أ إ ٱ -> ا. */
|
|
442
|
+
export interface ArqamTashkeelOptions {
|
|
443
|
+
tatweel?: "on" | "off";
|
|
444
|
+
hamza?: "on" | "off";
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** An instance from createArqam(): its own options, untouched by the global arqamAR and other instances.
|
|
448
|
+
* registerCurrency() writes the shared currency table. */
|
|
449
|
+
export interface ArqamInstance {
|
|
450
|
+
toWords(n: ArqamNumber, options?: ArqamOptions | string): string;
|
|
451
|
+
toWords(n: ArqamNumber[], options?: ArqamOptions | string): string[];
|
|
452
|
+
toParts(n: ArqamNumber, options?: ArqamOptions | string): ArqamParts;
|
|
453
|
+
toParts(n: ArqamNumber[], options?: ArqamOptions | string): ArqamParts[];
|
|
454
|
+
toDate(d: ArqamDate, options?: ArqamDateOptions): string;
|
|
455
|
+
toDate(d: ArqamDate[], options?: ArqamDateOptions): string[];
|
|
456
|
+
toTime(t: ArqamTime, options?: ArqamTimeOptions): string;
|
|
457
|
+
toTime(t: ArqamTime[], options?: ArqamTimeOptions): string[];
|
|
458
|
+
toFraction(f: ArqamFraction, options?: ArqamFractionOptions): string;
|
|
459
|
+
toFraction(f: ArqamFraction[], options?: ArqamFractionOptions): string[];
|
|
460
|
+
toDateTime(x: ArqamDateTime, options?: ArqamDateTimeOptions): string;
|
|
461
|
+
toDateTime(x: ArqamDateTime[], options?: ArqamDateTimeOptions): string[];
|
|
462
|
+
registerTimeZone(zone: string, name: string | null): string | null;
|
|
463
|
+
config(options?: ArqamOptions): void;
|
|
464
|
+
options(): ArqamOptions;
|
|
465
|
+
reset(): void;
|
|
466
|
+
registerCurrency(code: string, attributes: ArqamCurrencyAttributes): unknown[];
|
|
467
|
+
removeTashkeel(text: string, options?: ArqamTashkeelOptions): string;
|
|
468
|
+
removeTashkeel(text: string[], options?: ArqamTashkeelOptions): string[];
|
|
469
|
+
/** The نسبة adjective of a place name: قطر -> قطري، كوريا الشمالية -> كوري شمالي */
|
|
470
|
+
nisba(name: string, options?: ArqamNisbaOptions): string;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface Arqam {
|
|
474
|
+
/** The words; a 2nd parameter that is text is a currency code. */
|
|
475
|
+
toWords(n: ArqamNumber, options?: ArqamOptions | string): string;
|
|
476
|
+
toWords(n: ArqamNumber[], options?: ArqamOptions | string): string[];
|
|
477
|
+
toParts(n: ArqamNumber, options?: ArqamOptions | string): ArqamParts;
|
|
478
|
+
toParts(n: ArqamNumber[], options?: ArqamOptions | string): ArqamParts[];
|
|
479
|
+
/** A date in words; an array gives an array. */
|
|
480
|
+
toDate(d: ArqamDate, options?: ArqamDateOptions): string;
|
|
481
|
+
toDate(d: ArqamDate[], options?: ArqamDateOptions): string[];
|
|
482
|
+
/** A time in words: الساعة الرابعة إلا الربع عصرًا; an array gives an array. */
|
|
483
|
+
toTime(t: ArqamTime, options?: ArqamTimeOptions): string;
|
|
484
|
+
toTime(t: ArqamTime[], options?: ArqamTimeOptions): string[];
|
|
485
|
+
/** A typed fraction in words: 3/4 -> ثلاثة أرباع، 3 1/2 -> ثلاثة ونصف; an array gives an array. */
|
|
486
|
+
toFraction(f: ArqamFraction, options?: ArqamFractionOptions): string;
|
|
487
|
+
toFraction(f: ArqamFraction[], options?: ArqamFractionOptions): string[];
|
|
488
|
+
/** The date, «، », the time and its zone: …، الساعة التاسعة وخمس عشرة دقيقة صباحا بتوقيت الدوحة */
|
|
489
|
+
toDateTime(x: ArqamDateTime, options?: ArqamDateTimeOptions): string;
|
|
490
|
+
toDateTime(x: ArqamDateTime[], options?: ArqamDateTimeOptions): string[];
|
|
491
|
+
/** Your own Arabic name for any IANA zone (or instead of the built-in one); null takes it away */
|
|
492
|
+
registerTimeZone(zone: string, name: string | null): string | null;
|
|
493
|
+
/** The 22 Arab locales and what each gives */
|
|
494
|
+
readonly regions: Record<string, ArqamRegion>;
|
|
495
|
+
/** Every zone with an Arabic name: the 22, the 35 hubs and your own */
|
|
496
|
+
readonly timeZones: Record<string, ArqamZoneName>;
|
|
497
|
+
/** The engine's building blocks (cardinal, ordinal, count, parseDate, hijri, toCase, normalize, …) */
|
|
498
|
+
readonly utils: ArqamUtils;
|
|
499
|
+
/** A new instance with its own options, starting from the defaults. */
|
|
500
|
+
createArqam(options?: ArqamOptions): ArqamInstance;
|
|
501
|
+
/** Standing options for the calls that follow. */
|
|
502
|
+
config(options?: ArqamOptions): void;
|
|
503
|
+
/** Adds or modifies a currency for the session; returns a copy of its row. Throws a TypeError on a mistake. */
|
|
504
|
+
registerCurrency(code: string, attributes: ArqamCurrencyAttributes): unknown[];
|
|
505
|
+
/** Back to the default options (registered currencies stay). */
|
|
506
|
+
reset(): void;
|
|
507
|
+
/** A copy of the current options. */
|
|
508
|
+
options(): ArqamOptions;
|
|
509
|
+
/** Any text without its tashkeel: the 113 Arabic marks; an array gives an array. */
|
|
510
|
+
removeTashkeel(text: string, options?: ArqamTashkeelOptions): string;
|
|
511
|
+
removeTashkeel(text: string[], options?: ArqamTashkeelOptions): string[];
|
|
512
|
+
/** The نسبة adjective of a place name: قطر -> قطري، كوريا الشمالية -> كوري شمالي */
|
|
513
|
+
nisba(name: string, options?: ArqamNisbaOptions): string;
|
|
514
|
+
readonly version: string;
|
|
515
|
+
readonly currencies: ArqamCurrencyTable;
|
|
516
|
+
/** The Symbol of every currency that has one, by code: {SAR: "\u20C1", USD: "$", EUR: "€", …} */
|
|
517
|
+
readonly symbols: Record<string, string>;
|
|
518
|
+
/** The same as symbols (an older name) */
|
|
519
|
+
readonly signs: Record<string, string>;
|
|
520
|
+
readonly defaults: ArqamOptions;
|
|
521
|
+
/** The readable name of each coded value, e.g. optionNames.tashkeel.full === "f" */
|
|
522
|
+
readonly optionNames: ArqamOptionNames;
|
|
523
|
+
/** The Intl-style formatter: new arqamAR.NumberFormat("ar-QA", {style: "currency"}).format(1234.5) */
|
|
524
|
+
readonly NumberFormat: ArqamNumberFormatConstructor;
|
|
525
|
+
/** With the units add-on loaded (arqamUnits.js / "arqam/units"): the units for NumberFormat style "unit" */
|
|
526
|
+
units?: import("./arqamUnits.mjs").ArqamUnits;
|
|
527
|
+
/** With arqamWordsToNumbers loaded: the number in the words, or null (the reader's value()) */
|
|
528
|
+
fromWords?(text: string, options?: object): string | null;
|
|
529
|
+
/** With arqamWordsToNumbers loaded: a date toDate() wrote, back to "YYYY-MM-DD" ("… هـ" for Hijri), or null */
|
|
530
|
+
fromDate?(text: string): string | null;
|
|
531
|
+
/** With arqamWordsToNumbers loaded: a time toTime() wrote, back to "HH:MM", or null */
|
|
532
|
+
fromTime?(text: string): string | null;
|
|
533
|
+
/** With arqamWordsToNumbers loaded: every number in a text (the reader's find()) */
|
|
534
|
+
findNumbers?(text: string, options?: object): object[];
|
|
535
|
+
/** With arqamWordsToNumbers loaded: do the words say the number? (the reader's verify()) */
|
|
536
|
+
verify?(words: string, number: string | number | bigint, options?: object): {ok: boolean; reason: string; read: string | null; expected: string; currency: string | null};
|
|
537
|
+
/** With arqamExplain loaded: the grammar of the words, word by word (see arqamExplain.d.mts for the result). */
|
|
538
|
+
explain?: ((number: ArqamNumber, options?: ArqamOptions) => import("./arqamExplain.mjs").ArqamExplanation) &
|
|
539
|
+
((numbers: ArqamNumber[], options?: ArqamOptions) => import("./arqamExplain.mjs").ArqamExplanation[]) &
|
|
540
|
+
{date(input: ArqamDate, options?: ArqamDateOptions): import("./arqamExplain.mjs").ArqamExplanation};
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/** The Gregorian and Hijri day of a parsed date. */
|
|
544
|
+
export interface ArqamDay { year: number; month: number; day: number; }
|
|
545
|
+
/** arqamAR.utils, the engine's building blocks for developers. Each one that writes words takes the
|
|
546
|
+
* toWords options (tashkeel, ierab, …). A mistake throws a TypeError or RangeError named arqamAR.utils.<name>. */
|
|
547
|
+
export interface ArqamUtils {
|
|
548
|
+
/** The number words alone: cardinal(13, {gender: "feminine"}) -> ثلاث عشرة */
|
|
549
|
+
cardinal(n: ArqamNumber, options?: ArqamOptions & {gender?: "masculine" | "feminine" | "m" | "f"}): string;
|
|
550
|
+
/** The ordinal: ordinal(21, {gender: "feminine", definite: false}) -> حادية وعشرون */
|
|
551
|
+
ordinal(n: ArqamNumber, options?: ArqamOptions & {gender?: "masculine" | "feminine" | "m" | "f"; definite?: boolean | "on" | "off"}): string;
|
|
552
|
+
/** Any counted noun with the engine's grammar: count(11, {single: "سيارة", plural: "سيارات", gender: "feminine"}) ->
|
|
553
|
+
* إحدى عشرة سيارة. singleT / pluralT: the vowelled forms for full tashkeel (the plural in the genitive). 1 and 2 are the
|
|
554
|
+
* noun alone (كتاب، كتابان) unless keepOne. Whole numbers only (a RangeError otherwise). */
|
|
555
|
+
count(n: ArqamNumber, options: ArqamOptions & {single: string; plural: string; gender?: "masculine" | "feminine" | "m" | "f";
|
|
556
|
+
singleT?: string; pluralT?: string; keepOne?: boolean}): string;
|
|
557
|
+
/** The scale word of 10^(3 × power): scaleName(3) -> مليار */
|
|
558
|
+
scaleName(power: number | bigint, options?: {plural?: boolean; tashkeel?: boolean; scale?: "arabic" | "short" | "long"}): string;
|
|
559
|
+
/** A percentage: percent(25) -> خمسة وعشرون بالمائة */
|
|
560
|
+
percent(n: ArqamNumber, options?: ArqamOptions): string;
|
|
561
|
+
/** A date as Arqam reads it (or a TypeError/RangeError that says why) */
|
|
562
|
+
parseDate(text: ArqamDate, options?: {input?: "g" | "h" | "gregorian" | "hijri"; order?: "dmy" | "mdy"}): ArqamDay & {hijri: ArqamDay | null; date: Date};
|
|
563
|
+
/** A time of day, or a duration */
|
|
564
|
+
parseTime(text: ArqamTime, options?: {duration?: boolean}): {hour: number; minute: number; second: number};
|
|
565
|
+
/** A typed fraction: "3 1/2", "¾", "2.5" */
|
|
566
|
+
parseFraction(text: ArqamFraction): {whole: string; numerator: number; denominator: number};
|
|
567
|
+
/** The Hijri (Umm al-Qura) day of a date */
|
|
568
|
+
hijri(date: Date | string): ArqamDay;
|
|
569
|
+
/** The Gregorian day of a Hijri date (a RangeError if that day does not exist) */
|
|
570
|
+
fromHijri(year: number, month: number, day: number): ArqamDay & {date: Date};
|
|
571
|
+
/** Number words in another case: toCase("السادسُ والعشرون", "jarr") -> السادسِ والعشرين */
|
|
572
|
+
toCase(words: string, ierab: "raf" | "nasb" | "jarr" | "r" | "n" | "j"): string;
|
|
573
|
+
/** Text made comparable: no tashkeel or tatweel; أ إ آ ٱ -> ا، ى -> ي، ة -> ه، ؤ -> و، ئ -> ي */
|
|
574
|
+
normalize(text: string): string;
|
|
575
|
+
/** Arabic-Eastern or Persian digits to Arabic-Western ("western", the default), or Arabic-Western to Arabic-Eastern */
|
|
576
|
+
digits(text: string, to?: "western" | "eastern"): string;
|
|
577
|
+
/** The marks in Unicode's standard order (a letter, its vowel, then the shadda) */
|
|
578
|
+
markOrder(text: string): string;
|
|
579
|
+
/** "Did you mean": the nearest name of the list, or "" */
|
|
580
|
+
suggest(word: string, list: string[], options?: {distance?: number}): string;
|
|
581
|
+
/** Every option once, and what toDate, toTime, toFraction and toDateTime take */
|
|
582
|
+
readonly options: {options: Record<string, {default: string | number | null; kind: "switch" | "choice" | "text"; values: string[] | null; names: Record<string, string> | null}>;
|
|
583
|
+
calls: Record<"toDate" | "toTime" | "toFraction" | "toDateTime", {own?: string[]; shared: string[]}>};
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
declare const arqamAR: Arqam;
|
|
587
|
+
/** A language engine of the library: the words of a number or an amount in its language. */
|
|
588
|
+
export interface ArqamLanguage {
|
|
589
|
+
version: string;
|
|
590
|
+
toWords(n: ArqamNumber, options?: object | string): string;
|
|
591
|
+
config(options?: object): unknown;
|
|
592
|
+
registerCurrency(code: string, attributes: unknown): unknown;
|
|
593
|
+
[name: string]: unknown;
|
|
594
|
+
}
|
|
595
|
+
/** The library's NumberFormat, as Intl's one NumberFormat: the first locale whose language is loaded decides (ar, en …),
|
|
596
|
+
* and the call goes to that engine's NumberFormat with its own options; no locale: Arabic. */
|
|
597
|
+
export interface ArqamLibraryNumberFormat {
|
|
598
|
+
new (locales: string | string[], options?: ArqamNumberFormatOptions | import("./arqamEN.mjs").ArqamENNumberFormatOptions): ArqamNumberFormatInstance | import("./arqamEN.mjs").ArqamENNumberFormat;
|
|
599
|
+
new (options?: ArqamNumberFormatOptions): ArqamNumberFormatInstance;
|
|
600
|
+
(locales: string | string[], options?: ArqamNumberFormatOptions | import("./arqamEN.mjs").ArqamENNumberFormatOptions): ArqamNumberFormatInstance | import("./arqamEN.mjs").ArqamENNumberFormat;
|
|
601
|
+
(options?: ArqamNumberFormatOptions): ArqamNumberFormatInstance;
|
|
602
|
+
/** The locales of the list in a language Arqam has loaded */
|
|
603
|
+
supportedLocalesOf(locales?: string | string[]): string[];
|
|
604
|
+
readonly styles: ArqamNumberFormatStyle[];
|
|
605
|
+
}
|
|
606
|
+
/** The library, shaped as Intl: the locale chooses the language (Arabic by default); the other methods are Arabic. */
|
|
607
|
+
export interface ArqamLibrary extends Omit<Arqam, "NumberFormat" | "toWords"> {
|
|
608
|
+
/** arqam(n, locales, options) is arqam.toWords(n, locales, options); a currency code in place of the locales is the
|
|
609
|
+
* short form of an amount (engine 1.86): arqam("1250.50", "EGP") is arqam("1250.50", {currency: "EGP"}) */
|
|
610
|
+
(n: ArqamNumber, locales?: string | string[], options?: ArqamNumberFormatOptions | import("./arqamEN.mjs").ArqamENNumberFormatOptions): string;
|
|
611
|
+
(n: ArqamNumber, options?: ArqamNumberFormatOptions): string;
|
|
612
|
+
/** Every language, chosen by the locale */
|
|
613
|
+
readonly NumberFormat: ArqamLibraryNumberFormat;
|
|
614
|
+
/** As n.toLocaleString(locales, options): the words of new arqam.NumberFormat(locales, options).format(n).
|
|
615
|
+
* The options may come second when there is no locale. */
|
|
616
|
+
toWords(n: ArqamNumber, locales?: string | string[], options?: ArqamNumberFormatOptions | import("./arqamEN.mjs").ArqamENNumberFormatOptions): string;
|
|
617
|
+
toWords(n: ArqamNumber, options?: ArqamNumberFormatOptions): string;
|
|
618
|
+
toWords(n: ArqamNumber[], locales?: string | string[], options?: ArqamNumberFormatOptions | import("./arqamEN.mjs").ArqamENNumberFormatOptions): string[];
|
|
619
|
+
toWords(n: ArqamNumber[], options?: ArqamNumberFormatOptions): string[];
|
|
620
|
+
/** The amount in Arabic and English, with the figure (needs "arqam/en"). */
|
|
621
|
+
toBilingual(n: ArqamNumber, code: string, options?: ArqamJoinOptions): {ar: string; en: string; figure: string};
|
|
622
|
+
/** The amount in each language asked for, with the figure. */
|
|
623
|
+
toLanguages(n: ArqamNumber, code: string, languages: string[], options?: ArqamJoinOptions): {[language: string]: string; figure: string};
|
|
624
|
+
/** The wording of a cheque, invoice, receipt or contract article, in one language or several. */
|
|
625
|
+
toClause: {
|
|
626
|
+
(kind: ArqamDocument, n: ArqamNumber, code: string, options?: ArqamClauseOptions & {lang?: string}): ArqamClause;
|
|
627
|
+
(kind: ArqamDocument, n: ArqamNumber, code: string, options: ArqamClauseOptions & {lang: string[]}): {[language: string]: ArqamClause} & {text: string};
|
|
628
|
+
readonly wording: {[language: string]: {[kind: string]: {[label: string]: string}}};
|
|
629
|
+
readonly kinds: ArqamDocument[];
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
export type ArqamDocument = "cheque" | "invoice" | "receipt" | "contract";
|
|
633
|
+
/** Options of toBilingual() and toLanguages(). */
|
|
634
|
+
export interface ArqamJoinOptions {
|
|
635
|
+
/** "off" leaves out «فقط … لا غير» and "Only". */
|
|
636
|
+
only?: "on" | "off" | boolean;
|
|
637
|
+
/** Where "Only" goes in English (default "end"). */
|
|
638
|
+
onlyEn?: "end" | "start";
|
|
639
|
+
/** The Arabic tashkeel (default "a": the tanween on the alif, as on cheques). */
|
|
640
|
+
tashkeel?: string;
|
|
641
|
+
/** The English style (default "uk": One Thousand Two Hundred and Fifty). */
|
|
642
|
+
style?: "uk" | "us";
|
|
643
|
+
}
|
|
644
|
+
/** Options of toClause(). */
|
|
645
|
+
export interface ArqamClauseOptions extends ArqamJoinOptions {
|
|
646
|
+
payee?: string; for?: string; ref?: string;
|
|
647
|
+
date?: string | Date;
|
|
648
|
+
/** The Hijri date beside the date. */
|
|
649
|
+
hijri?: boolean;
|
|
650
|
+
/** The article number of a contract (default 1). */
|
|
651
|
+
clause?: number | string;
|
|
652
|
+
}
|
|
653
|
+
export interface ArqamClause { text: string; lines: string[]; words: string; figure: string; }
|
|
654
|
+
declare const arqam: ArqamLibrary;
|
|
655
|
+
export default arqam;
|
|
656
|
+
export {arqam, arqamAR};
|
|
657
|
+
export declare const version: string;
|
|
658
|
+
export declare const currencies: ArqamCurrencyTable;
|
|
659
|
+
/** arqam.toWords: (n, locales, options), as n.toLocaleString; a currency alone is an amount */
|
|
660
|
+
export declare const toWords: ArqamLibrary["toWords"];
|
|
661
|
+
export declare function toParts(n: ArqamNumber, options?: ArqamOptions | string): ArqamParts;
|
|
662
|
+
export declare function toParts(n: ArqamNumber[], options?: ArqamOptions | string): ArqamParts[];
|
|
663
|
+
export declare function toDate(d: ArqamDate, options?: ArqamDateOptions): string;
|
|
664
|
+
export declare function toDate(d: ArqamDate[], options?: ArqamDateOptions): string[];
|
|
665
|
+
export declare function toTime(t: ArqamTime, options?: ArqamTimeOptions): string;
|
|
666
|
+
export declare function toTime(t: ArqamTime[], options?: ArqamTimeOptions): string[];
|
|
667
|
+
export declare function toFraction(f: ArqamFraction, options?: ArqamFractionOptions): string;
|
|
668
|
+
export declare function toFraction(f: ArqamFraction[], options?: ArqamFractionOptions): string[];
|
|
669
|
+
export declare function createArqam(options?: ArqamOptions): ArqamInstance;
|
|
670
|
+
export declare function config(options?: ArqamOptions): void;
|
|
671
|
+
export declare function registerCurrency(code: string, attributes: ArqamCurrencyAttributes): unknown[];
|
|
672
|
+
export declare function reset(): void;
|
|
673
|
+
export declare function options(): ArqamOptions;
|
|
674
|
+
export declare function removeTashkeel(text: string, options?: ArqamTashkeelOptions): string;
|
|
675
|
+
export declare function removeTashkeel(text: string[], options?: ArqamTashkeelOptions): string[];
|
|
676
|
+
export declare function nisba(name: string, options?: ArqamNisbaOptions): string;
|
|
677
|
+
/** arqam.NumberFormat: the locale chooses the language */
|
|
678
|
+
export declare const NumberFormat: ArqamLibraryNumberFormat;
|
|
679
|
+
export declare function toDateTime(x: ArqamDateTime, options?: ArqamDateTimeOptions): string;
|
|
680
|
+
export declare function toDateTime(x: ArqamDateTime[], options?: ArqamDateTimeOptions): string[];
|
|
681
|
+
export declare function registerTimeZone(zone: string, name: string | null): string | null;
|
|
682
|
+
/** The engine's building blocks */
|
|
683
|
+
export declare const utils: ArqamUtils;
|