nhb-toolbox 4.28.7 → 4.28.8
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 +4 -0
- package/dist/cjs/date/constants.js +1 -6
- package/dist/cjs/date/guards.js +2 -2
- package/dist/cjs/date/parse.js +1 -1
- package/dist/dts/date/constants.d.ts +0 -2
- package/dist/dts/date/types.d.ts +5 -1
- package/dist/esm/date/constants.js +0 -5
- package/dist/esm/date/guards.js +2 -2
- package/dist/esm/date/parse.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@ All notable changes to the package will be documented here.
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [4.28.8] - 2025-12-03
|
|
10
|
+
|
|
11
|
+
- **Fixed** a *tree-shaking issue* affecting `Chronos` and other *date/time utilities* by removing a *pre-compiled* `RegExp` instance from **date/constants**.
|
|
12
|
+
|
|
9
13
|
## [4.28.7] - 2025-12-02
|
|
10
14
|
|
|
11
15
|
- **Updated** *invalid links* in *tsdoc* of the *hash utilities*.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MS_MAP = exports.
|
|
3
|
+
exports.MS_MAP = exports.TIME_UNIT_VARIANTS = exports.ZODIAC_PRESETS = exports.VEDIC_ZODIAC_SIGNS = exports.WESTERN_ZODIAC_SIGNS = exports.DATE_PART_RANGES = exports.SORTED_TIME_FORMATS = exports.TIME_FORMATS = exports.MILLISECOND_FORMATS = exports.ZONE_FORMATS = exports.SECOND_FORMATS = exports.MINUTE_FORMATS = exports.HOUR_FORMATS = exports.DAY_FORMATS = exports.DATE_FORMATS = exports.MONTH_FORMATS = exports.YEAR_FORMATS = exports.MONTHS = exports.DAYS = exports.INTERNALS = void 0;
|
|
4
4
|
exports.INTERNALS = Symbol('Internals');
|
|
5
5
|
exports.DAYS = /* @__PURE__ */ Object.freeze([
|
|
6
6
|
'Sunday',
|
|
@@ -106,11 +106,6 @@ exports.TIME_UNIT_VARIANTS = /* @__PURE__ */ Object.freeze({
|
|
|
106
106
|
second: ['s', 'sec', 'secs', 'second', 'seconds'],
|
|
107
107
|
millisecond: ['ms', 'msec', 'msecs', 'millisecond', 'milliseconds'],
|
|
108
108
|
});
|
|
109
|
-
const TIME_UNIT_REGEX_STR = /* @__PURE__ */ Object.freeze(Object.values(exports.TIME_UNIT_VARIANTS)
|
|
110
|
-
.flat()
|
|
111
|
-
.sort((a, b) => b.length - a.length)
|
|
112
|
-
.join('|'));
|
|
113
|
-
exports.TIME_UNIT_REGEX = /* @__PURE__ */ Object.freeze(new RegExp(`^(?<value>-?\\d*\\.?\\d+) *(?<unit>${TIME_UNIT_REGEX_STR})?$`, 'i'));
|
|
114
109
|
exports.MS_MAP = /* @__PURE__ */ Object.freeze((() => {
|
|
115
110
|
const s = 1000;
|
|
116
111
|
const m = s * 60;
|
package/dist/cjs/date/guards.js
CHANGED
|
@@ -10,7 +10,6 @@ exports.isTimeWithUnit = isTimeWithUnit;
|
|
|
10
10
|
const primitives_1 = require("../guards/primitives");
|
|
11
11
|
const specials_1 = require("../guards/specials");
|
|
12
12
|
const utilities_1 = require("../number/utilities");
|
|
13
|
-
const constants_1 = require("./constants");
|
|
14
13
|
const timezone_1 = require("./timezone");
|
|
15
14
|
function isValidTime(value) {
|
|
16
15
|
if (!(0, primitives_1.isNonEmptyString)(value))
|
|
@@ -67,5 +66,6 @@ function isDateLike(value) {
|
|
|
67
66
|
return false;
|
|
68
67
|
}
|
|
69
68
|
function isTimeWithUnit(value) {
|
|
70
|
-
return (0, primitives_1.isNonEmptyString)(value) &&
|
|
69
|
+
return ((0, primitives_1.isNonEmptyString)(value) &&
|
|
70
|
+
/^-?\d*\.?\d+ *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.test(value));
|
|
71
71
|
}
|
package/dist/cjs/date/parse.js
CHANGED
|
@@ -21,7 +21,7 @@ function _parse(str, sec = false) {
|
|
|
21
21
|
if (!(0, primitives_1.isNonEmptyString)(str) || str.length > 100) {
|
|
22
22
|
throw new RangeError(`Value must be a string with length between 1 and 99!`);
|
|
23
23
|
}
|
|
24
|
-
const match =
|
|
24
|
+
const match = /^(?<value>-?\d*\.?\d+) *(?<unit>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.exec(str);
|
|
25
25
|
if (!match?.groups)
|
|
26
26
|
return NaN;
|
|
27
27
|
const unit = (match.groups.unit ?? 'ms').toLowerCase();
|
|
@@ -40,7 +40,5 @@ export declare const TIME_UNIT_VARIANTS: Readonly<{
|
|
|
40
40
|
readonly second: readonly ["s", "sec", "secs", "second", "seconds"];
|
|
41
41
|
readonly millisecond: readonly ["ms", "msec", "msecs", "millisecond", "milliseconds"];
|
|
42
42
|
}>;
|
|
43
|
-
/** `RegExp` for time unit variants */
|
|
44
|
-
export declare const TIME_UNIT_REGEX: Readonly<RegExp>;
|
|
45
43
|
/** Map to different time units to milliseconds */
|
|
46
44
|
export declare const MS_MAP: Readonly<Record<"year" | "y" | "yr" | "yrs" | "years" | "month" | "mo" | "months" | "week" | "w" | "weeks" | "day" | "d" | "days" | "hour" | "h" | "hr" | "hrs" | "hours" | "minute" | "m" | "min" | "mins" | "minutes" | "second" | "s" | "sec" | "secs" | "seconds" | "millisecond" | "ms" | "msec" | "msecs" | "milliseconds", number>>;
|
package/dist/dts/date/types.d.ts
CHANGED
|
@@ -486,8 +486,12 @@ export type ChronosWithOptions = Partial<{
|
|
|
486
486
|
/** Milliseconds of the second, from 0 to 999. */
|
|
487
487
|
millisecond: Milliseconds;
|
|
488
488
|
}>;
|
|
489
|
+
/** Mapped type to {@link TIME_UNIT_VARIANTS} */
|
|
490
|
+
export type $TimeUnitVarMap = typeof TIME_UNIT_VARIANTS;
|
|
491
|
+
/** Key of {@link TIME_UNIT_VARIANTS} */
|
|
492
|
+
export type $TimeUnitKey = keyof typeof TIME_UNIT_VARIANTS;
|
|
489
493
|
/** Variants of different time units in lowercase */
|
|
490
|
-
export type $TimeUnitVar =
|
|
494
|
+
export type $TimeUnitVar<U extends $TimeUnitKey = $TimeUnitKey> = $TimeUnitVarMap[U][number];
|
|
491
495
|
/** Variants of different time units in lowercase, uppercase and capitalized */
|
|
492
496
|
export type $UnitAnyCase = Capitalize<$TimeUnitVar> | Uppercase<$TimeUnitVar> | $TimeUnitVar;
|
|
493
497
|
/** Number (time value) with variants of different time units */
|
|
@@ -103,11 +103,6 @@ export const TIME_UNIT_VARIANTS = /* @__PURE__ */ Object.freeze({
|
|
|
103
103
|
second: ['s', 'sec', 'secs', 'second', 'seconds'],
|
|
104
104
|
millisecond: ['ms', 'msec', 'msecs', 'millisecond', 'milliseconds'],
|
|
105
105
|
});
|
|
106
|
-
const TIME_UNIT_REGEX_STR = /* @__PURE__ */ Object.freeze(Object.values(TIME_UNIT_VARIANTS)
|
|
107
|
-
.flat()
|
|
108
|
-
.sort((a, b) => b.length - a.length)
|
|
109
|
-
.join('|'));
|
|
110
|
-
export const TIME_UNIT_REGEX = /* @__PURE__ */ Object.freeze(new RegExp(`^(?<value>-?\\d*\\.?\\d+) *(?<unit>${TIME_UNIT_REGEX_STR})?$`, 'i'));
|
|
111
106
|
export const MS_MAP = /* @__PURE__ */ Object.freeze((() => {
|
|
112
107
|
const s = 1000;
|
|
113
108
|
const m = s * 60;
|
package/dist/esm/date/guards.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isNonEmptyString, isString } from '../guards/primitives.js';
|
|
2
2
|
import { isNumericString } from '../guards/specials.js';
|
|
3
3
|
import { normalizeNumber } from '../number/utilities.js';
|
|
4
|
-
import { TIME_UNIT_REGEX } from './constants.js';
|
|
5
4
|
import { IANA_TZ_IDS } from './timezone.js';
|
|
6
5
|
export function isValidTime(value) {
|
|
7
6
|
if (!isNonEmptyString(value))
|
|
@@ -58,5 +57,6 @@ export function isDateLike(value) {
|
|
|
58
57
|
return false;
|
|
59
58
|
}
|
|
60
59
|
export function isTimeWithUnit(value) {
|
|
61
|
-
return isNonEmptyString(value) &&
|
|
60
|
+
return (isNonEmptyString(value) &&
|
|
61
|
+
/^-?\d*\.?\d+ *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.test(value));
|
|
62
62
|
}
|
package/dist/esm/date/parse.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNonEmptyString, isNumber } from '../guards/primitives.js';
|
|
2
2
|
import { isNumericString } from '../guards/specials.js';
|
|
3
|
-
import { MS_MAP
|
|
3
|
+
import { MS_MAP } from './constants.js';
|
|
4
4
|
import { isTimeWithUnit } from './guards.js';
|
|
5
5
|
export function parseMSec(value, sec = false) {
|
|
6
6
|
if (isNumericString(value)) {
|
|
@@ -18,7 +18,7 @@ function _parse(str, sec = false) {
|
|
|
18
18
|
if (!isNonEmptyString(str) || str.length > 100) {
|
|
19
19
|
throw new RangeError(`Value must be a string with length between 1 and 99!`);
|
|
20
20
|
}
|
|
21
|
-
const match =
|
|
21
|
+
const match = /^(?<value>-?\d*\.?\d+) *(?<unit>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.exec(str);
|
|
22
22
|
if (!match?.groups)
|
|
23
23
|
return NaN;
|
|
24
24
|
const unit = (match.groups.unit ?? 'ms').toLowerCase();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "4.28.
|
|
3
|
+
"version": "4.28.8",
|
|
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",
|