bn-calendar 1.2.2 → 1.2.4
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/README.md +9 -9
- package/dist/dist-BSh0fQzq.mjs +255 -0
- package/dist/dist-BasKGWW6.cjs +303 -0
- package/dist/index.cjs +45 -21
- package/dist/index.d.cts +18 -2
- package/dist/index.d.mts +18 -2
- package/dist/index.mjs +26 -2
- package/dist/{types-dBV02J9_.d.mts → object-D70hzkoY-JjxsmDJd.d.cts} +97 -37
- package/dist/{types-CCT6pdoz.d.cts → object-D70hzkoY-JjxsmDJd.d.mts} +97 -37
- package/dist/{types-x2X_wAiB.d.cts → types-BKGg1Ls7.d.cts} +17 -1
- package/dist/{types-DuIqPJJ1.d.mts → types-CdJOp5Bk.d.mts} +17 -1
- package/dist/types.cjs +16 -0
- package/dist/types.d.cts +17 -1
- package/dist/types.d.mts +17 -1
- package/dist/types.mjs +16 -0
- package/dist/utils.cjs +19 -3
- package/dist/utils.d.cts +28 -4
- package/dist/utils.d.mts +28 -4
- package/dist/utils.mjs +17 -1
- package/package.json +8 -6
- package/dist/convert-BetQIRvF.cjs +0 -128
- package/dist/convert-CYpIfNZ_.mjs +0 -80
package/README.md
CHANGED
|
@@ -96,10 +96,10 @@ import { BanglaCalendar } from 'bn-calendar';
|
|
|
96
96
|
- [Quick Examples](#quick-examples)
|
|
97
97
|
- [API Reference](#api-reference)
|
|
98
98
|
- [Constructor](#constructor)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
- [Constructor Signatures](#constructor-signatures)
|
|
100
|
+
- [Parameters](#parameters)
|
|
101
|
+
- [Behavior](#behavior)
|
|
102
|
+
- [Examples](#examples)
|
|
103
103
|
- [Properties](#properties)
|
|
104
104
|
- [variant](#variant)
|
|
105
105
|
- [year](#year)
|
|
@@ -191,7 +191,7 @@ const date5 = new BanglaCalendar('১৪৩০', '১', '১', { variant: 'revis
|
|
|
191
191
|
|
|
192
192
|
Creates a new `BanglaCalendar` instance from various input formats.
|
|
193
193
|
|
|
194
|
-
|
|
194
|
+
#### Constructor Signatures
|
|
195
195
|
|
|
196
196
|
**Signature 1:** From current date with optional configuration
|
|
197
197
|
|
|
@@ -257,7 +257,7 @@ constructor(
|
|
|
257
257
|
)
|
|
258
258
|
```
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
#### Parameters
|
|
261
261
|
|
|
262
262
|
- `date`: Various date formats including Bangla date strings, Gregorian date strings, Date objects, timestamps, or individual date components
|
|
263
263
|
- `bnYear`: Bengali year in either Bangla (`০-৯৯৯৯`) or Latin (`0-9999`) digits
|
|
@@ -265,7 +265,7 @@ constructor(
|
|
|
265
265
|
- `bnDate`: Bengali day of month (1-31 or `১-৩১`)
|
|
266
266
|
- `config`: Optional configuration object with `variant` property (`'revised-2019'` or `'revised-1966'`)
|
|
267
267
|
|
|
268
|
-
|
|
268
|
+
#### Behavior
|
|
269
269
|
|
|
270
270
|
- Automatically detects input format and parses accordingly
|
|
271
271
|
- Defaults to current date if no valid input is provided
|
|
@@ -273,7 +273,7 @@ constructor(
|
|
|
273
273
|
- Validates all date components
|
|
274
274
|
- Handles leap years according to the selected variant
|
|
275
275
|
|
|
276
|
-
|
|
276
|
+
#### Examples
|
|
277
277
|
|
|
278
278
|
```typescript
|
|
279
279
|
// Current date
|
|
@@ -1497,7 +1497,7 @@ import { banglaToDigit, digitToBangla } from 'bn-calendar/utils'
|
|
|
1497
1497
|
|
|
1498
1498
|
> [!NOTE]
|
|
1499
1499
|
>
|
|
1500
|
-
> `banglaToDigit()` and `digitToBangla()` functions are imported from the [**
|
|
1500
|
+
> `banglaToDigit()` and `digitToBangla()` functions are imported from the [**toolbox-x**](https://toolbox-x.nazmul-nhb.dev/) package.
|
|
1501
1501
|
|
|
1502
1502
|
The digit conversion utilities provide seamless conversion between Bangla (Bengali) digits (`০-৯`) and Latin (Arabic) digits (`0-9`). These functions are essential for applications that need to handle multilingual numeric representations, particularly in Bengali-language interfaces.
|
|
1503
1503
|
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/primitives-Djsevc69.mjs
|
|
18
|
+
/**
|
|
19
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
20
|
+
*
|
|
21
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
22
|
+
* you may not use this file except in compliance with the License.
|
|
23
|
+
* You may obtain a copy of the License at
|
|
24
|
+
*
|
|
25
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26
|
+
*
|
|
27
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
28
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
29
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
30
|
+
* See the License for the specific language governing permissions and
|
|
31
|
+
* limitations under the License.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* * Type guard to check whether a value is a finite number (excluding `NaN` and `Infinity`).
|
|
35
|
+
* @param value - The value to test.
|
|
36
|
+
* @returns `true` if the value is a finite number; otherwise `false`.
|
|
37
|
+
*/
|
|
38
|
+
function isNumber(value) {
|
|
39
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* * Type guard to check if a value is a string.
|
|
43
|
+
* @param value - The value to check.
|
|
44
|
+
* @returns `true` if the value is a string, otherwise `false`.
|
|
45
|
+
*/
|
|
46
|
+
function isString(value) {
|
|
47
|
+
return typeof value === "string";
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* * Type guard to check if a value is an integer.
|
|
51
|
+
* @param value - The value to check.
|
|
52
|
+
* @returns `true` if the value is an integer, otherwise `false`.
|
|
53
|
+
*/
|
|
54
|
+
function isInteger(value) {
|
|
55
|
+
return isNumber(value) && Number.isInteger(value);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* * Type guard to check if a value is a non-empty string.
|
|
59
|
+
* @param value - The value to check.
|
|
60
|
+
* @returns `true` if the value is a non-empty string, otherwise `false`.
|
|
61
|
+
*/
|
|
62
|
+
function isNonEmptyString(value) {
|
|
63
|
+
return isString(value) && value?.length > 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/constants-ZyfpysiQ.mjs
|
|
68
|
+
/** * Bangla digits from `০-৯` mapped against `0-9` */
|
|
69
|
+
const BN_DIGITS = /* @__PURE__ */ Object.freeze({
|
|
70
|
+
"০": 0,
|
|
71
|
+
"১": 1,
|
|
72
|
+
"২": 2,
|
|
73
|
+
"৩": 3,
|
|
74
|
+
"৪": 4,
|
|
75
|
+
"৫": 5,
|
|
76
|
+
"৬": 6,
|
|
77
|
+
"৭": 7,
|
|
78
|
+
"৮": 8,
|
|
79
|
+
"৯": 9
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/specials-Cye93-uo.mjs
|
|
84
|
+
/**
|
|
85
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
86
|
+
*
|
|
87
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
88
|
+
* you may not use this file except in compliance with the License.
|
|
89
|
+
* You may obtain a copy of the License at
|
|
90
|
+
*
|
|
91
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
92
|
+
*
|
|
93
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
94
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
95
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
96
|
+
* See the License for the specific language governing permissions and
|
|
97
|
+
* limitations under the License.
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* * Type guard to check if a value is an array.
|
|
101
|
+
* @param value - The value to check.
|
|
102
|
+
* @returns `true` if the value is an array, otherwise `false`.
|
|
103
|
+
*/
|
|
104
|
+
function isArray(value) {
|
|
105
|
+
return Array.isArray(value);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* * Type guard to check if a value is an object (excluding null).
|
|
109
|
+
* @param value - The value to check.
|
|
110
|
+
* @returns `true` if the value is an object, otherwise `false`.
|
|
111
|
+
*/
|
|
112
|
+
function isObject(value) {
|
|
113
|
+
return value !== null && typeof value === "object" && !isArray(value);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* * Type guard to check if a value is an object with specific keys.
|
|
117
|
+
* @param value - The value to check.
|
|
118
|
+
* @param keys - The list of keys the object should contain.
|
|
119
|
+
* @returns `true` if the value is an object with the specified keys, otherwise `false`.
|
|
120
|
+
*/
|
|
121
|
+
function isObjectWithKeys(value, keys) {
|
|
122
|
+
return isObject(value) && keys?.every((key) => key in value);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* * Type guard to check if a value is a valid date string.
|
|
126
|
+
* @param value - The value to check.
|
|
127
|
+
* @returns `true` if the value is a valid date string, otherwise `false`.
|
|
128
|
+
*/
|
|
129
|
+
function isDateString(value) {
|
|
130
|
+
return isString(value) && !isNaN(Date.parse(value));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* * Type guard to check if a value is a string representing a finite number.
|
|
134
|
+
*
|
|
135
|
+
* @remarks
|
|
136
|
+
* - Accepts strings like: `"42"`, `" -5.5 "`, `"0.123"`, `"-0"`, `"1e5"`.
|
|
137
|
+
* - Rejects strings like: `"NaN"`, `"Infinity"`, `"-Infinity"`, `"abc"`, `""`, `"42abc"`.
|
|
138
|
+
*
|
|
139
|
+
* @param value - The value to test.
|
|
140
|
+
* @returns `true` if the value is a string that fully represents a finite number.
|
|
141
|
+
*/
|
|
142
|
+
function isNumericString(value) {
|
|
143
|
+
return isString(value) && value?.trim() !== "" && Number.isFinite(Number(value));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/utilities-B9axOvOX.mjs
|
|
148
|
+
/**
|
|
149
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
150
|
+
*
|
|
151
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
152
|
+
* you may not use this file except in compliance with the License.
|
|
153
|
+
* You may obtain a copy of the License at
|
|
154
|
+
*
|
|
155
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
156
|
+
*
|
|
157
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
158
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
159
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
160
|
+
* See the License for the specific language governing permissions and
|
|
161
|
+
* limitations under the License.
|
|
162
|
+
*/
|
|
163
|
+
/**
|
|
164
|
+
* * Normalize a number or numeric string to a number.
|
|
165
|
+
* @description
|
|
166
|
+
* This function checks if the input is a number or a numeric string and converts it to a number.
|
|
167
|
+
* If the input is not a valid number or numeric string, it returns `undefined`.
|
|
168
|
+
* @param num - The number to normalize.
|
|
169
|
+
* @returns The normalized number or `undefined` if the input is not a valid number or numeric string.
|
|
170
|
+
*/
|
|
171
|
+
function normalizeNumber(num) {
|
|
172
|
+
return isNumber(num) ? num : isNumericString(num) ? Number(num) : void 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/index.mjs
|
|
177
|
+
/**
|
|
178
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
179
|
+
*
|
|
180
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
* you may not use this file except in compliance with the License.
|
|
182
|
+
* You may obtain a copy of the License at
|
|
183
|
+
*
|
|
184
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
*
|
|
186
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
* See the License for the specific language governing permissions and
|
|
190
|
+
* limitations under the License.
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* * Converts Bangla (Arabic system) digits to Latin (Arabic system) digits.
|
|
194
|
+
*
|
|
195
|
+
* @remarks
|
|
196
|
+
* - Behavior depends on the `forceNumber` flag:
|
|
197
|
+
* - When `forceNumber` is `true`, always returns a `number` (strips non-digit characters).
|
|
198
|
+
* - Returns `NaN` if the input is non empty string or does not include any numeric string.
|
|
199
|
+
* - When `forceNumber` is `false`, always returns a string, including non-digit characters.
|
|
200
|
+
* - Returns empty string if the input is non empty string.
|
|
201
|
+
*
|
|
202
|
+
* @param bnDigit - A string containing Bangla (Arabic system) digits.
|
|
203
|
+
* @param forceNumber - Whether to force number conversion even if the input includes non-digit character(s). Default is `false`.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* banglaToDigit('১২৩abc'); // 123
|
|
207
|
+
* banglaToDigit(''); // NaN
|
|
208
|
+
* banglaToDigit('৪৫৬'); // 456
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* banglaToDigit('১২৩', false); // "123"
|
|
212
|
+
* banglaToDigit('১২৩abc', false); // "123abc"
|
|
213
|
+
*/
|
|
214
|
+
function banglaToDigit(bnDigit, forceNumber = true) {
|
|
215
|
+
if (!isNonEmptyString(bnDigit)) return forceNumber ? NaN : "";
|
|
216
|
+
const digitStr = bnDigit.replace(/[০১২৩৪৫৬৭৮৯]/g, (d) => String(BN_DIGITS[d]));
|
|
217
|
+
if (forceNumber) return Number(digitStr.split("").filter((dig) => !isNaN(Number(dig))).join(""));
|
|
218
|
+
return digitStr;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* * Converts Latin (Arabic system) digits to Bangla digits (Arabic system).
|
|
222
|
+
*
|
|
223
|
+
* @remarks
|
|
224
|
+
* - Accepts numbers or numeric strings including non-digit characters.
|
|
225
|
+
* - When `preserveNonDigit` is `true`, non-digit characters are preserved in the output.
|
|
226
|
+
* - When `preserveNonDigit` is `false`, non-numeric strings are stripped.
|
|
227
|
+
* - Returns empty string for invalid input.
|
|
228
|
+
*
|
|
229
|
+
* @param digit - A number or string containing Latin (Arabic system) digits.
|
|
230
|
+
* @param preserveNonDigit - Whether to preserve non-digit characters in the output. Default is `true`.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* digitToBangla(123); // "১২৩"
|
|
234
|
+
* digitToBangla('456'); // "৪৫৬"
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* digitToBangla('12ab', false); // "১২"
|
|
238
|
+
* digitToBangla('12ab'); // "১২ab"
|
|
239
|
+
*/
|
|
240
|
+
function digitToBangla(digit, preserveNonDigit = true) {
|
|
241
|
+
const banglaDigits = Object.keys(BN_DIGITS);
|
|
242
|
+
const _matchAndConvert = (value) => {
|
|
243
|
+
return value.replace(/\d/g, (dig) => banglaDigits[Number(dig)]);
|
|
244
|
+
};
|
|
245
|
+
if (isNumber(digit)) return _matchAndConvert(String(digit));
|
|
246
|
+
if (isNonEmptyString(digit)) {
|
|
247
|
+
const bnDigStr = _matchAndConvert(digit);
|
|
248
|
+
if (preserveNonDigit || isNumericString(digit)) return bnDigStr;
|
|
249
|
+
return bnDigStr.split("").filter((dig) => banglaDigits.includes(dig)).join("");
|
|
250
|
+
}
|
|
251
|
+
return "";
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
//#endregion
|
|
255
|
+
export { isObjectWithKeys as a, isNumber as c, isDateString as i, digitToBangla as n, isInteger as o, normalizeNumber as r, isNonEmptyString as s, banglaToDigit as t };
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/primitives-Djsevc69.mjs
|
|
19
|
+
/**
|
|
20
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
21
|
+
*
|
|
22
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
23
|
+
* you may not use this file except in compliance with the License.
|
|
24
|
+
* You may obtain a copy of the License at
|
|
25
|
+
*
|
|
26
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
+
*
|
|
28
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
29
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
+
* See the License for the specific language governing permissions and
|
|
32
|
+
* limitations under the License.
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* * Type guard to check whether a value is a finite number (excluding `NaN` and `Infinity`).
|
|
36
|
+
* @param value - The value to test.
|
|
37
|
+
* @returns `true` if the value is a finite number; otherwise `false`.
|
|
38
|
+
*/
|
|
39
|
+
function isNumber(value) {
|
|
40
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* * Type guard to check if a value is a string.
|
|
44
|
+
* @param value - The value to check.
|
|
45
|
+
* @returns `true` if the value is a string, otherwise `false`.
|
|
46
|
+
*/
|
|
47
|
+
function isString(value) {
|
|
48
|
+
return typeof value === "string";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* * Type guard to check if a value is an integer.
|
|
52
|
+
* @param value - The value to check.
|
|
53
|
+
* @returns `true` if the value is an integer, otherwise `false`.
|
|
54
|
+
*/
|
|
55
|
+
function isInteger(value) {
|
|
56
|
+
return isNumber(value) && Number.isInteger(value);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* * Type guard to check if a value is a non-empty string.
|
|
60
|
+
* @param value - The value to check.
|
|
61
|
+
* @returns `true` if the value is a non-empty string, otherwise `false`.
|
|
62
|
+
*/
|
|
63
|
+
function isNonEmptyString(value) {
|
|
64
|
+
return isString(value) && value?.length > 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/constants-ZyfpysiQ.mjs
|
|
69
|
+
/** * Bangla digits from `০-৯` mapped against `0-9` */
|
|
70
|
+
const BN_DIGITS = /* @__PURE__ */ Object.freeze({
|
|
71
|
+
"০": 0,
|
|
72
|
+
"১": 1,
|
|
73
|
+
"২": 2,
|
|
74
|
+
"৩": 3,
|
|
75
|
+
"৪": 4,
|
|
76
|
+
"৫": 5,
|
|
77
|
+
"৬": 6,
|
|
78
|
+
"৭": 7,
|
|
79
|
+
"৮": 8,
|
|
80
|
+
"৯": 9
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/specials-Cye93-uo.mjs
|
|
85
|
+
/**
|
|
86
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
87
|
+
*
|
|
88
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
89
|
+
* you may not use this file except in compliance with the License.
|
|
90
|
+
* You may obtain a copy of the License at
|
|
91
|
+
*
|
|
92
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
93
|
+
*
|
|
94
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
95
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
96
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
97
|
+
* See the License for the specific language governing permissions and
|
|
98
|
+
* limitations under the License.
|
|
99
|
+
*/
|
|
100
|
+
/**
|
|
101
|
+
* * Type guard to check if a value is an array.
|
|
102
|
+
* @param value - The value to check.
|
|
103
|
+
* @returns `true` if the value is an array, otherwise `false`.
|
|
104
|
+
*/
|
|
105
|
+
function isArray(value) {
|
|
106
|
+
return Array.isArray(value);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* * Type guard to check if a value is an object (excluding null).
|
|
110
|
+
* @param value - The value to check.
|
|
111
|
+
* @returns `true` if the value is an object, otherwise `false`.
|
|
112
|
+
*/
|
|
113
|
+
function isObject(value) {
|
|
114
|
+
return value !== null && typeof value === "object" && !isArray(value);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* * Type guard to check if a value is an object with specific keys.
|
|
118
|
+
* @param value - The value to check.
|
|
119
|
+
* @param keys - The list of keys the object should contain.
|
|
120
|
+
* @returns `true` if the value is an object with the specified keys, otherwise `false`.
|
|
121
|
+
*/
|
|
122
|
+
function isObjectWithKeys(value, keys) {
|
|
123
|
+
return isObject(value) && keys?.every((key) => key in value);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* * Type guard to check if a value is a valid date string.
|
|
127
|
+
* @param value - The value to check.
|
|
128
|
+
* @returns `true` if the value is a valid date string, otherwise `false`.
|
|
129
|
+
*/
|
|
130
|
+
function isDateString(value) {
|
|
131
|
+
return isString(value) && !isNaN(Date.parse(value));
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* * Type guard to check if a value is a string representing a finite number.
|
|
135
|
+
*
|
|
136
|
+
* @remarks
|
|
137
|
+
* - Accepts strings like: `"42"`, `" -5.5 "`, `"0.123"`, `"-0"`, `"1e5"`.
|
|
138
|
+
* - Rejects strings like: `"NaN"`, `"Infinity"`, `"-Infinity"`, `"abc"`, `""`, `"42abc"`.
|
|
139
|
+
*
|
|
140
|
+
* @param value - The value to test.
|
|
141
|
+
* @returns `true` if the value is a string that fully represents a finite number.
|
|
142
|
+
*/
|
|
143
|
+
function isNumericString(value) {
|
|
144
|
+
return isString(value) && value?.trim() !== "" && Number.isFinite(Number(value));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/utilities-B9axOvOX.mjs
|
|
149
|
+
/**
|
|
150
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
151
|
+
*
|
|
152
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
153
|
+
* you may not use this file except in compliance with the License.
|
|
154
|
+
* You may obtain a copy of the License at
|
|
155
|
+
*
|
|
156
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
157
|
+
*
|
|
158
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
159
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
160
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
161
|
+
* See the License for the specific language governing permissions and
|
|
162
|
+
* limitations under the License.
|
|
163
|
+
*/
|
|
164
|
+
/**
|
|
165
|
+
* * Normalize a number or numeric string to a number.
|
|
166
|
+
* @description
|
|
167
|
+
* This function checks if the input is a number or a numeric string and converts it to a number.
|
|
168
|
+
* If the input is not a valid number or numeric string, it returns `undefined`.
|
|
169
|
+
* @param num - The number to normalize.
|
|
170
|
+
* @returns The normalized number or `undefined` if the input is not a valid number or numeric string.
|
|
171
|
+
*/
|
|
172
|
+
function normalizeNumber(num) {
|
|
173
|
+
return isNumber(num) ? num : isNumericString(num) ? Number(num) : void 0;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region node_modules/.pnpm/toolbox-x@1.0.1-rc.6/node_modules/toolbox-x/dist/index.mjs
|
|
178
|
+
/**
|
|
179
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
180
|
+
*
|
|
181
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
* you may not use this file except in compliance with the License.
|
|
183
|
+
* You may obtain a copy of the License at
|
|
184
|
+
*
|
|
185
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
*
|
|
187
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
* See the License for the specific language governing permissions and
|
|
191
|
+
* limitations under the License.
|
|
192
|
+
*/
|
|
193
|
+
/**
|
|
194
|
+
* * Converts Bangla (Arabic system) digits to Latin (Arabic system) digits.
|
|
195
|
+
*
|
|
196
|
+
* @remarks
|
|
197
|
+
* - Behavior depends on the `forceNumber` flag:
|
|
198
|
+
* - When `forceNumber` is `true`, always returns a `number` (strips non-digit characters).
|
|
199
|
+
* - Returns `NaN` if the input is non empty string or does not include any numeric string.
|
|
200
|
+
* - When `forceNumber` is `false`, always returns a string, including non-digit characters.
|
|
201
|
+
* - Returns empty string if the input is non empty string.
|
|
202
|
+
*
|
|
203
|
+
* @param bnDigit - A string containing Bangla (Arabic system) digits.
|
|
204
|
+
* @param forceNumber - Whether to force number conversion even if the input includes non-digit character(s). Default is `false`.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* banglaToDigit('১২৩abc'); // 123
|
|
208
|
+
* banglaToDigit(''); // NaN
|
|
209
|
+
* banglaToDigit('৪৫৬'); // 456
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* banglaToDigit('১২৩', false); // "123"
|
|
213
|
+
* banglaToDigit('১২৩abc', false); // "123abc"
|
|
214
|
+
*/
|
|
215
|
+
function banglaToDigit(bnDigit, forceNumber = true) {
|
|
216
|
+
if (!isNonEmptyString(bnDigit)) return forceNumber ? NaN : "";
|
|
217
|
+
const digitStr = bnDigit.replace(/[০১২৩৪৫৬৭৮৯]/g, (d) => String(BN_DIGITS[d]));
|
|
218
|
+
if (forceNumber) return Number(digitStr.split("").filter((dig) => !isNaN(Number(dig))).join(""));
|
|
219
|
+
return digitStr;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* * Converts Latin (Arabic system) digits to Bangla digits (Arabic system).
|
|
223
|
+
*
|
|
224
|
+
* @remarks
|
|
225
|
+
* - Accepts numbers or numeric strings including non-digit characters.
|
|
226
|
+
* - When `preserveNonDigit` is `true`, non-digit characters are preserved in the output.
|
|
227
|
+
* - When `preserveNonDigit` is `false`, non-numeric strings are stripped.
|
|
228
|
+
* - Returns empty string for invalid input.
|
|
229
|
+
*
|
|
230
|
+
* @param digit - A number or string containing Latin (Arabic system) digits.
|
|
231
|
+
* @param preserveNonDigit - Whether to preserve non-digit characters in the output. Default is `true`.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* digitToBangla(123); // "১২৩"
|
|
235
|
+
* digitToBangla('456'); // "৪৫৬"
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* digitToBangla('12ab', false); // "১২"
|
|
239
|
+
* digitToBangla('12ab'); // "১২ab"
|
|
240
|
+
*/
|
|
241
|
+
function digitToBangla(digit, preserveNonDigit = true) {
|
|
242
|
+
const banglaDigits = Object.keys(BN_DIGITS);
|
|
243
|
+
const _matchAndConvert = (value) => {
|
|
244
|
+
return value.replace(/\d/g, (dig) => banglaDigits[Number(dig)]);
|
|
245
|
+
};
|
|
246
|
+
if (isNumber(digit)) return _matchAndConvert(String(digit));
|
|
247
|
+
if (isNonEmptyString(digit)) {
|
|
248
|
+
const bnDigStr = _matchAndConvert(digit);
|
|
249
|
+
if (preserveNonDigit || isNumericString(digit)) return bnDigStr;
|
|
250
|
+
return bnDigStr.split("").filter((dig) => banglaDigits.includes(dig)).join("");
|
|
251
|
+
}
|
|
252
|
+
return "";
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
//#endregion
|
|
256
|
+
Object.defineProperty(exports, 'banglaToDigit', {
|
|
257
|
+
enumerable: true,
|
|
258
|
+
get: function () {
|
|
259
|
+
return banglaToDigit;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
Object.defineProperty(exports, 'digitToBangla', {
|
|
263
|
+
enumerable: true,
|
|
264
|
+
get: function () {
|
|
265
|
+
return digitToBangla;
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
Object.defineProperty(exports, 'isDateString', {
|
|
269
|
+
enumerable: true,
|
|
270
|
+
get: function () {
|
|
271
|
+
return isDateString;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
Object.defineProperty(exports, 'isInteger', {
|
|
275
|
+
enumerable: true,
|
|
276
|
+
get: function () {
|
|
277
|
+
return isInteger;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
Object.defineProperty(exports, 'isNonEmptyString', {
|
|
281
|
+
enumerable: true,
|
|
282
|
+
get: function () {
|
|
283
|
+
return isNonEmptyString;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
Object.defineProperty(exports, 'isNumber', {
|
|
287
|
+
enumerable: true,
|
|
288
|
+
get: function () {
|
|
289
|
+
return isNumber;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
Object.defineProperty(exports, 'isObjectWithKeys', {
|
|
293
|
+
enumerable: true,
|
|
294
|
+
get: function () {
|
|
295
|
+
return isObjectWithKeys;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
Object.defineProperty(exports, 'normalizeNumber', {
|
|
299
|
+
enumerable: true,
|
|
300
|
+
get: function () {
|
|
301
|
+
return normalizeNumber;
|
|
302
|
+
}
|
|
303
|
+
});
|