nhb-toolbox 4.28.52 → 4.28.53

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/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  All notable changes to the package will be documented here.
6
6
 
7
+ ## [4.28.53] - 2026-01-01
8
+
9
+ - **Optimized** *internal utilities* to enhance **runtime performance** and **editor IntelliSense**.
10
+
7
11
  ## [4.28.52] - 2025-12-30
8
12
 
9
13
  - **Added** *new* methods for `BanglaCalendar`: `addDays`, `addWeeks`, `addMonths`, `addYears`, `valueOf` and `[Symbol.toPrimitive]`.
@@ -6,16 +6,15 @@ const specials_1 = require("../guards/specials");
6
6
  const constants_1 = require("./constants");
7
7
  const guards_1 = require("./guards");
8
8
  function parseMSec(value, sec = false) {
9
- if ((0, specials_1.isNumericString)(value)) {
9
+ if ((0, primitives_1.isNumber)(value) || (0, specials_1.isNumericString)(value)) {
10
10
  return _parse(`${value}s`, sec);
11
11
  }
12
12
  else if ((0, guards_1.isTimeWithUnit)(value)) {
13
13
  return _parse(value, sec);
14
14
  }
15
- else if ((0, primitives_1.isNumber)(value)) {
16
- return _parse(`${value}s`, sec);
15
+ else {
16
+ return NaN;
17
17
  }
18
- return NaN;
19
18
  }
20
19
  function _parse(str, sec = false) {
21
20
  if (!(0, primitives_1.isNonEmptyString)(str) || str.length > 100) {
@@ -1,11 +1,11 @@
1
1
  import type { Enumerate, NumberRange } from '../number/types';
2
2
  import type { Maybe } from '../types/index';
3
3
  import type { $BnEn, $GMTOffset, $TimeZoneIdentifier, BanglaSeasonName, BnCalendarVariant, TimeZoneNameNative } from './types';
4
- /** Core formatting logic shared by `formatDate` and `Chronos` class */
4
+ /** Core formatting logic shared by `formatDate` and `Chronos`, `BanglaCalendar` classes */
5
5
  export declare function _formatDateCore(format: string, dateComponents: Record<string, string>): string;
6
6
  /** Core formatting logic shared by `formatDate` and `Chronos` class */
7
7
  export declare function _formatDate(format: string, year: number, month: number, day: number, date: number, hours: number, minutes: number, seconds: number, milliseconds: number, offset: string): string;
8
- /** Normalize a time string with by adding offset at the end */
8
+ /** Normalize a time string by adding offset at the end */
9
9
  export declare function _normalizeOffset(timeStr: string): string;
10
10
  /** Converts milliseconds to seconds */
11
11
  export declare const _toSeconds: (ms: number) => number;
@@ -18,8 +18,11 @@ type $ResolvedTzName<T extends $TzNameType> = Maybe<T extends 'long' ? TimeZoneN
18
18
  export declare function _resolveNativeTzName<T extends $TzNameType>(tzId: $TzId, type: T, date?: Date): $ResolvedTzName<T>;
19
19
  /** Convert `GMT±HH:mm` string to `UTC±HH:mm` format*/
20
20
  export declare function _gmtToUtcOffset(gmt: Maybe<string>): Maybe<"UTC+00:15" | "UTC+00:30" | "UTC+00:45" | "UTC+00:00" | "UTC+01:15" | "UTC+01:30" | "UTC+01:45" | "UTC+01:00" | "UTC+02:15" | "UTC+02:30" | "UTC+02:45" | "UTC+02:00" | "UTC+03:15" | "UTC+03:30" | "UTC+03:45" | "UTC+03:00" | "UTC+04:15" | "UTC+04:30" | "UTC+04:45" | "UTC+04:00" | "UTC+05:15" | "UTC+05:30" | "UTC+05:45" | "UTC+05:00" | "UTC+06:15" | "UTC+06:30" | "UTC+06:45" | "UTC+06:00" | "UTC+07:15" | "UTC+07:30" | "UTC+07:45" | "UTC+07:00" | "UTC+08:15" | "UTC+08:30" | "UTC+08:45" | "UTC+08:00" | "UTC+09:15" | "UTC+09:30" | "UTC+09:45" | "UTC+09:00" | "UTC+10:15" | "UTC+10:30" | "UTC+10:45" | "UTC+10:00" | "UTC+14:15" | "UTC+14:30" | "UTC+14:45" | "UTC+14:00" | "UTC+11:15" | "UTC+11:30" | "UTC+11:45" | "UTC+11:00" | "UTC+12:15" | "UTC+12:30" | "UTC+12:45" | "UTC+12:00" | "UTC+13:15" | "UTC+13:30" | "UTC+13:45" | "UTC+13:00" | "UTC-00:15" | "UTC-00:30" | "UTC-00:45" | "UTC-00:00" | "UTC-01:15" | "UTC-01:30" | "UTC-01:45" | "UTC-01:00" | "UTC-02:15" | "UTC-02:30" | "UTC-02:45" | "UTC-02:00" | "UTC-03:15" | "UTC-03:30" | "UTC-03:45" | "UTC-03:00" | "UTC-04:15" | "UTC-04:30" | "UTC-04:45" | "UTC-04:00" | "UTC-05:15" | "UTC-05:30" | "UTC-05:45" | "UTC-05:00" | "UTC-06:15" | "UTC-06:30" | "UTC-06:45" | "UTC-06:00" | "UTC-07:15" | "UTC-07:30" | "UTC-07:45" | "UTC-07:00" | "UTC-08:15" | "UTC-08:30" | "UTC-08:45" | "UTC-08:00" | "UTC-09:15" | "UTC-09:30" | "UTC-09:45" | "UTC-09:00" | "UTC-10:15" | "UTC-10:30" | "UTC-10:45" | "UTC-10:00" | "UTC-14:15" | "UTC-14:30" | "UTC-14:45" | "UTC-14:00" | "UTC-11:15" | "UTC-11:30" | "UTC-11:45" | "UTC-11:00" | "UTC-12:15" | "UTC-12:30" | "UTC-12:45" | "UTC-12:00" | "UTC-13:15" | "UTC-13:30" | "UTC-13:45" | "UTC-13:00">;
21
+ /** Get Bangla season name by month index (`0-11`) */
21
22
  export declare function _getBnSeason<L extends $BnEn = 'bn'>(month: number, locale?: L | $BnEn): BanglaSeasonName<L>;
23
+ /** Check whether a Bangla year is leap by Gregorian and Bangla years and calendar variant */
22
24
  export declare function _isBnLeapYear(by: number, gy: number, v?: BnCalendarVariant): boolean;
25
+ /** Extract selective unit values from {@link Date} object */
23
26
  export declare function _extractDateUnits(date: Date): {
24
27
  gy: number;
25
28
  $gm: Enumerate<12>;
@@ -27,10 +30,15 @@ export declare function _extractDateUnits(date: Date): {
27
30
  gd: NumberRange<1, 31>;
28
31
  wd: Enumerate<7>;
29
32
  };
33
+ /** Get Gregorian base year from {@link Date} object for Bangla year */
30
34
  export declare function _getGregBaseYear(date: Date): number;
35
+ /** Get Bangla year from {@link Date} object */
31
36
  export declare function _getBnYear(date: Date): number;
37
+ /** Get timestamp in milliseconds between midnight, January 1, 1970 (UTC) and the specified {@link Date} object */
32
38
  export declare function _getUtcTs(date: Date): number;
39
+ /** Get number of days elapsed since midnight April 14, 1970 (UTC) for specific {@link Date} */
33
40
  export declare function _getElapsedDays(date: Date): number;
41
+ /** Get number of days elapsed since midnight April 14, 1970 (UTC) and month index for specific `Date` and Bangla calendar variant */
34
42
  export declare function _bnDaysMonthIdx(date: Date, variant?: BnCalendarVariant): {
35
43
  days: number;
36
44
  monthIdx: number;
@@ -3,16 +3,15 @@ import { isNumericString } from '../guards/specials.js';
3
3
  import { MS_MAP } from './constants.js';
4
4
  import { isTimeWithUnit } from './guards.js';
5
5
  export function parseMSec(value, sec = false) {
6
- if (isNumericString(value)) {
6
+ if (isNumber(value) || isNumericString(value)) {
7
7
  return _parse(`${value}s`, sec);
8
8
  }
9
9
  else if (isTimeWithUnit(value)) {
10
10
  return _parse(value, sec);
11
11
  }
12
- else if (isNumber(value)) {
13
- return _parse(`${value}s`, sec);
12
+ else {
13
+ return NaN;
14
14
  }
15
- return NaN;
16
15
  }
17
16
  function _parse(str, sec = false) {
18
17
  if (!isNonEmptyString(str) || str.length > 100) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nhb-toolbox",
3
- "version": "4.28.52",
3
+ "version": "4.28.53",
4
4
  "description": "A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -47,8 +47,8 @@
47
47
  "@eslint/js": "^9.39.2",
48
48
  "@types/jest": "^30.0.0",
49
49
  "@types/node": "^25.0.3",
50
- "@typescript-eslint/eslint-plugin": "^8.50.1",
51
- "@typescript-eslint/parser": "^8.50.1",
50
+ "@typescript-eslint/eslint-plugin": "^8.51.0",
51
+ "@typescript-eslint/parser": "^8.51.0",
52
52
  "eslint": "^9.39.2",
53
53
  "eslint-config-prettier": "^10.1.8",
54
54
  "eslint-plugin-prettier": "^5.5.4",
@@ -60,7 +60,7 @@
60
60
  "prettier": "^3.7.4",
61
61
  "ts-jest": "^29.4.6",
62
62
  "typescript": "^5.9.3",
63
- "typescript-eslint": "^8.50.1"
63
+ "typescript-eslint": "^8.51.0"
64
64
  },
65
65
  "keywords": [
66
66
  "toolbox",