nhb-toolbox 4.23.21 → 4.23.24
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 +12 -3
- package/dist/cjs/constants.js +3 -2
- package/dist/cjs/converter/base.js +4 -1
- package/dist/dts/constants.d.ts +2 -2
- package/dist/dts/converter/base.d.ts +5 -8
- package/dist/dts/converter/types.d.ts +1 -2
- package/dist/esm/constants.js +2 -2
- package/dist/esm/converter/base.js +4 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,15 @@ All notable changes to the package will be documented here.
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [4.23.24] - 2025-10-26
|
|
10
|
+
|
|
11
|
+
- **Fixed** *pluralization issue* with ***suffixed*** `'-foot' --> '-feet'` for *format methods* in *converter classes*.
|
|
12
|
+
|
|
13
|
+
## [4.23.23] - 2025-10-26
|
|
14
|
+
|
|
15
|
+
- **Fixed** *pluralization issue* with `'foot' --> 'feet'` for *format methods* in *converter classes*.
|
|
16
|
+
- **Renamed** the export of `GENERAL_UNITS` (used in `Unit` class) and `CATEGORIZED_UNITS` (used in `Converter` classes) from `'nhb-toolbox/constants'`.
|
|
17
|
+
|
|
9
18
|
## [4.23.21] - 2025-10-25
|
|
10
19
|
|
|
11
20
|
- **Fixed** *return type* (now maintains *proper order* in the *tuple*) for `supportedUnits()` *converter method*.
|
|
@@ -13,7 +22,7 @@ All notable changes to the package will be documented here.
|
|
|
13
22
|
## [4.23.20] - 2025-10-25
|
|
14
23
|
|
|
15
24
|
- **Fixed** *return type* for `supportedUnits()` *converter method*.
|
|
16
|
-
- **Added** *new package subpath* for `Color` class: `nhb-toolbox/color`.
|
|
25
|
+
- **Added** *new package subpath* for `Color` class: `'nhb-toolbox/color'`.
|
|
17
26
|
|
|
18
27
|
## [4.23.11] - 2025-10-24
|
|
19
28
|
|
|
@@ -28,13 +37,13 @@ All notable changes to the package will be documented here.
|
|
|
28
37
|
|
|
29
38
|
## [4.23.1] - 2025-10-24
|
|
30
39
|
|
|
31
|
-
- **Exported** *all the converter classes* from the `nhb-toolbox/converter` sub-path too.
|
|
40
|
+
- **Exported** *all the converter classes* from the `'nhb-toolbox/converter'` sub-path too.
|
|
32
41
|
|
|
33
42
|
## [4.23.0] - 2025-10-24
|
|
34
43
|
|
|
35
44
|
- **Added** new *unit converter classes* and their *combined function* `Converter` (aliased `converter`).
|
|
36
45
|
- **Introduced** new *utility types:* `Replace` `ReplaceFirst` and `$Record`.
|
|
37
|
-
- **Exported** `pluralizer`, `verbalizer`, `httpStatus` and new `Converter` utility through *package sub-paths*.
|
|
46
|
+
- **Exported** `pluralizer`, `verbalizer`, `httpStatus` and new `Converter` utility through different *package sub-paths*.
|
|
38
47
|
|
|
39
48
|
## [4.21.14] - 2025-10-14
|
|
40
49
|
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.STATUS_CODES = exports.HTTP_STATUS_CODES = exports.HTTP_STATUS = exports.HTTP_CODES = exports.COUNTRIES = exports.
|
|
3
|
+
exports.STATUS_CODES = exports.HTTP_STATUS_CODES = exports.HTTP_STATUS = exports.HTTP_CODES = exports.COUNTRIES = exports.CATEGORIZED_UNITS = exports.LOWERCASED_WORDS = exports.LOCALE_CODES = exports.GENERAL_UNITS = exports.FRANKFURTER_CURRENCIES = exports.CURRENCY_LOCALES = exports.CURRENCY_CODES = exports.CSS_COLORS = exports.NUMBER_COLOR_PALETTE = exports.ALPHABET_COLOR_PALETTE = exports.WESTERN_SEASONS = exports.US_ACADEMIC_SEASONS = exports.SEASON_PRESETS = exports.PHILIPPINES_SEASONS = exports.JAPAN_SEASONS = exports.INDIA_VEDIC_SEASONS = exports.INDIA_TAMIL_SEASONS = exports.INDIA_IMD_SEASONS = exports.ETHIOPIA_SEASONS = exports.BANGLADESH_SEASONS = exports.AUSTRALIA_SEASONS = exports.WESTERN_ZODIAC_SIGNS = exports.WEEK_DAYS = exports.VEDIC_ZODIAC_SIGNS = exports.TIME_ZONES = exports.TIME_ZONE_LABELS = exports.MONTHS = void 0;
|
|
4
4
|
var constants_1 = require("./date/constants");
|
|
5
5
|
Object.defineProperty(exports, "MONTHS", { enumerable: true, get: function () { return constants_1.MONTHS; } });
|
|
6
6
|
Object.defineProperty(exports, "TIME_ZONE_LABELS", { enumerable: true, get: function () { return constants_1.TIME_ZONE_LABELS; } });
|
|
@@ -29,11 +29,12 @@ var constants_3 = require("./number/constants");
|
|
|
29
29
|
Object.defineProperty(exports, "CURRENCY_CODES", { enumerable: true, get: function () { return constants_3.CURRENCY_CODES; } });
|
|
30
30
|
Object.defineProperty(exports, "CURRENCY_LOCALES", { enumerable: true, get: function () { return constants_3.CURRENCY_LOCALES; } });
|
|
31
31
|
Object.defineProperty(exports, "FRANKFURTER_CURRENCIES", { enumerable: true, get: function () { return constants_3.SUPPORTED_CURRENCIES; } });
|
|
32
|
+
Object.defineProperty(exports, "GENERAL_UNITS", { enumerable: true, get: function () { return constants_3.UNITS; } });
|
|
32
33
|
Object.defineProperty(exports, "LOCALE_CODES", { enumerable: true, get: function () { return constants_3.LOCALE_CODES; } });
|
|
33
34
|
var constants_4 = require("./string/constants");
|
|
34
35
|
Object.defineProperty(exports, "LOWERCASED_WORDS", { enumerable: true, get: function () { return constants_4.LOWERCASE; } });
|
|
35
36
|
var constants_5 = require("./converter/constants");
|
|
36
|
-
Object.defineProperty(exports, "
|
|
37
|
+
Object.defineProperty(exports, "CATEGORIZED_UNITS", { enumerable: true, get: function () { return constants_5.UNITS; } });
|
|
37
38
|
var countries_1 = require("./object/countries");
|
|
38
39
|
Object.defineProperty(exports, "COUNTRIES", { enumerable: true, get: function () { return countries_1.COUNTRIES; } });
|
|
39
40
|
var constants_6 = require("./http-status/constants");
|
|
@@ -13,7 +13,10 @@ class $BaseConverter {
|
|
|
13
13
|
const abs = Math.abs(value ?? this.value);
|
|
14
14
|
const u = unit ?? this.unit;
|
|
15
15
|
const pluralized = abs <= 1 ? u
|
|
16
|
-
: u ?
|
|
16
|
+
: u ?
|
|
17
|
+
u?.endsWith('foot') ?
|
|
18
|
+
u.replace(/foot$/, 'feet')
|
|
19
|
+
: `${u}s`
|
|
17
20
|
: '';
|
|
18
21
|
return `${abs} ${pluralized}`.trim();
|
|
19
22
|
}
|
package/dist/dts/constants.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export { MONTHS, TIME_ZONE_LABELS, TIME_ZONES, VEDIC_ZODIAC_SIGNS, DAYS as WEEK_
|
|
|
2
2
|
export { AUSTRALIA_SEASONS, BANGLADESH_SEASONS, ETHIOPIA_SEASONS, INDIA_IMD_SEASONS, INDIA_TAMIL_SEASONS, INDIA_VEDIC_SEASONS, JAPAN_SEASONS, PHILIPPINES_SEASONS, SEASON_PRESETS, US_ACADEMIC_SEASONS, DEFAULT_SEASONS as WESTERN_SEASONS, } from './date/seasons';
|
|
3
3
|
export { ALPHABET_COLOR_PALETTE, NUMBER_COLOR_PALETTE } from './colors/constants';
|
|
4
4
|
export { CSS_COLORS } from './colors/css-colors';
|
|
5
|
-
export { CURRENCY_CODES, CURRENCY_LOCALES, SUPPORTED_CURRENCIES as FRANKFURTER_CURRENCIES, LOCALE_CODES, } from './number/constants';
|
|
5
|
+
export { CURRENCY_CODES, CURRENCY_LOCALES, SUPPORTED_CURRENCIES as FRANKFURTER_CURRENCIES, UNITS as GENERAL_UNITS, LOCALE_CODES, } from './number/constants';
|
|
6
6
|
export { LOWERCASE as LOWERCASED_WORDS } from './string/constants';
|
|
7
|
-
export { UNITS } from './converter/constants';
|
|
7
|
+
export { UNITS as CATEGORIZED_UNITS } from './converter/constants';
|
|
8
8
|
export { COUNTRIES } from './object/countries';
|
|
9
9
|
export { HTTP_STATUS_CODES as HTTP_CODES, HTTP_STATUS_CODES as HTTP_STATUS, HTTP_STATUS_CODES, HTTP_STATUS_CODES as STATUS_CODES, } from './http-status/constants';
|
|
@@ -48,7 +48,6 @@ export declare class $BaseConverter<Unit extends $Unit> {
|
|
|
48
48
|
* @remarks
|
|
49
49
|
* - This method is automatically called when the instance is used in a string context.
|
|
50
50
|
* - For complex and versatile pluralization, please refer to {@link https://toolbox.nazmul-nhb.dev/docs/utilities/string/pluralizer pluralizer} or {@link https://toolbox.nazmul-nhb.dev/docs/classes/Pluralizer Pluralizer Class} instead.
|
|
51
|
-
|
|
52
51
|
*/
|
|
53
52
|
toString(): string;
|
|
54
53
|
/**
|
|
@@ -64,9 +63,7 @@ export declare class $BaseConverter<Unit extends $Unit> {
|
|
|
64
63
|
* @returns JSON string of `{ value, unit }`.
|
|
65
64
|
*/
|
|
66
65
|
toJSON(): string;
|
|
67
|
-
/**
|
|
68
|
-
* @instance Returns a new instance with the absolute value.
|
|
69
|
-
*/
|
|
66
|
+
/** @instance Returns a new instance with the absolute value. */
|
|
70
67
|
abs(): this;
|
|
71
68
|
/**
|
|
72
69
|
* @instance Adds a numeric value (same unit assumed).
|
|
@@ -90,15 +87,15 @@ export declare class $BaseConverter<Unit extends $Unit> {
|
|
|
90
87
|
divide(n: Numeric): this;
|
|
91
88
|
/**
|
|
92
89
|
* @instance Rounds to given decimal places.
|
|
93
|
-
* @param decimals Number of decimal places to round.
|
|
90
|
+
* @param decimals Number of decimal places to round. Default is `0`.
|
|
94
91
|
* @returns A new instance with rounded value.
|
|
95
92
|
*/
|
|
96
93
|
round(decimals?: number): this;
|
|
97
|
-
/**
|
|
94
|
+
/** @instance Returns whether this value is greater than another numeric value. */
|
|
98
95
|
gt(n: Numeric): boolean;
|
|
99
|
-
/**
|
|
96
|
+
/** @instance Returns whether this value is less than another numeric value. */
|
|
100
97
|
lt(n: Numeric): boolean;
|
|
101
|
-
/**
|
|
98
|
+
/** @instance Returns whether this value equals another numeric value. */
|
|
102
99
|
eq(n: Numeric): boolean;
|
|
103
100
|
/**
|
|
104
101
|
* @instance Returns a human-friendly formatted string with fixed decimals (if the value is fraction).
|
|
@@ -9,7 +9,7 @@ import type { $Temperature } from './temp';
|
|
|
9
9
|
import type { $Time } from './time';
|
|
10
10
|
import type { $Volume } from './volume';
|
|
11
11
|
/** - Type for Record of Units */
|
|
12
|
-
type UnitsRecord = typeof UNITS;
|
|
12
|
+
export type UnitsRecord = typeof UNITS;
|
|
13
13
|
/** * Category of units supported by the converter. */
|
|
14
14
|
export type Category = keyof UnitsRecord;
|
|
15
15
|
/** * Map of unit categories to their respective units. */
|
|
@@ -51,4 +51,3 @@ export type $TempUnit = UnitMap['temp'];
|
|
|
51
51
|
export type $TimeUnit = UnitMap['time'];
|
|
52
52
|
/** Union type for all the volume units */
|
|
53
53
|
export type $VolumeUnit = UnitMap['volume'];
|
|
54
|
-
export {};
|
package/dist/esm/constants.js
CHANGED
|
@@ -2,8 +2,8 @@ export { MONTHS, TIME_ZONE_LABELS, TIME_ZONES, VEDIC_ZODIAC_SIGNS, DAYS as WEEK_
|
|
|
2
2
|
export { AUSTRALIA_SEASONS, BANGLADESH_SEASONS, ETHIOPIA_SEASONS, INDIA_IMD_SEASONS, INDIA_TAMIL_SEASONS, INDIA_VEDIC_SEASONS, JAPAN_SEASONS, PHILIPPINES_SEASONS, SEASON_PRESETS, US_ACADEMIC_SEASONS, DEFAULT_SEASONS as WESTERN_SEASONS, } from './date/seasons.js';
|
|
3
3
|
export { ALPHABET_COLOR_PALETTE, NUMBER_COLOR_PALETTE } from './colors/constants.js';
|
|
4
4
|
export { CSS_COLORS } from './colors/css-colors.js';
|
|
5
|
-
export { CURRENCY_CODES, CURRENCY_LOCALES, SUPPORTED_CURRENCIES as FRANKFURTER_CURRENCIES, LOCALE_CODES, } from './number/constants.js';
|
|
5
|
+
export { CURRENCY_CODES, CURRENCY_LOCALES, SUPPORTED_CURRENCIES as FRANKFURTER_CURRENCIES, UNITS as GENERAL_UNITS, LOCALE_CODES, } from './number/constants.js';
|
|
6
6
|
export { LOWERCASE as LOWERCASED_WORDS } from './string/constants.js';
|
|
7
|
-
export { UNITS } from './converter/constants.js';
|
|
7
|
+
export { UNITS as CATEGORIZED_UNITS } from './converter/constants.js';
|
|
8
8
|
export { COUNTRIES } from './object/countries.js';
|
|
9
9
|
export { HTTP_STATUS_CODES as HTTP_CODES, HTTP_STATUS_CODES as HTTP_STATUS, HTTP_STATUS_CODES, HTTP_STATUS_CODES as STATUS_CODES, } from './http-status/constants.js';
|
|
@@ -10,7 +10,10 @@ export class $BaseConverter {
|
|
|
10
10
|
const abs = Math.abs(value ?? this.value);
|
|
11
11
|
const u = unit ?? this.unit;
|
|
12
12
|
const pluralized = abs <= 1 ? u
|
|
13
|
-
: u ?
|
|
13
|
+
: u ?
|
|
14
|
+
u?.endsWith('foot') ?
|
|
15
|
+
u.replace(/foot$/, 'feet')
|
|
16
|
+
: `${u}s`
|
|
14
17
|
: '';
|
|
15
18
|
return `${abs} ${pluralized}`.trim();
|
|
16
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "4.23.
|
|
3
|
+
"version": "4.23.24",
|
|
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",
|