nhb-toolbox 4.23.11 → 4.23.20

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.
@@ -1,7 +1,7 @@
1
1
  import type { $Record } from '../object/types';
2
2
  import type { Numeric } from '../types/index';
3
3
  import { $BaseConverter } from './base';
4
- import type { $AreaUnit, ConverterFormatOptions } from './types';
4
+ import type { $AreaUnit, FormatToOptions } from './types';
5
5
  /**
6
6
  * @class AreaConverter
7
7
  * @description Handles conversions with smart `.to()`, `.toAll()`, and `.formatTo()`.
@@ -30,5 +30,5 @@ export declare class $Area extends $BaseConverter<$AreaUnit> {
30
30
  * @param options Formatting options.
31
31
  * @returns Formatted string like "5km²", "5.02 square-miles", or "5e+3 meter".
32
32
  */
33
- formatTo(target: $AreaUnit, options?: ConverterFormatOptions): string;
33
+ formatTo(target: $AreaUnit, options?: FormatToOptions): string;
34
34
  }
@@ -1,6 +1,6 @@
1
1
  import type { Numeric } from '../types/index';
2
2
  import type { Tuple } from '../utils/types';
3
- import type { $Unit, Category, CategoryUnits, ConverterFormatOptions } from './types';
3
+ import type { $Unit, Category, CategoryUnits, FormatToOptions, Units } from './types';
4
4
  /**
5
5
  * @description Base class providing common mathematical and formatting utilities
6
6
  * for all unit converters (time, length, data, temperature, etc.).
@@ -26,7 +26,7 @@ export declare class $BaseConverter<Unit extends $Unit> {
26
26
  * @param options Formatting options.
27
27
  * @returns Formatted string according to style (compact, plural, scientific).
28
28
  */
29
- protected $formatTo(value: number, target: Unit, shortLabels: Record<Unit, string>, options: ConverterFormatOptions | undefined): string;
29
+ protected $formatTo(value: number, target: Unit, shortLabels: Record<Unit, string>, options: FormatToOptions | undefined): string;
30
30
  /**
31
31
  * @instance Returns the numeric value.
32
32
  * @returns The raw numeric value without unit.
@@ -113,7 +113,7 @@ export declare class $BaseConverter<Unit extends $Unit> {
113
113
  * @instance Returns all supported units.
114
114
  * @returns Array of supported unit strings.
115
115
  */
116
- supportedUnits(): Array<$Unit>;
116
+ supportedUnits(): Units;
117
117
  /**
118
118
  * @instance Returns all supported units for a specific category.
119
119
  * @param category Category to filter units by.
@@ -1,7 +1,7 @@
1
1
  import type { $Record } from '../object/types';
2
2
  import type { Numeric } from '../types/index';
3
3
  import { $BaseConverter } from './base';
4
- import type { $DataUnit, ConverterFormatOptions } from './types';
4
+ import type { $DataUnit, FormatToOptions } from './types';
5
5
  /**
6
6
  * @class DataConverter
7
7
  * @description Handles conversions with smart `.to()`, `.toAll()`, and `.formatTo()`.
@@ -30,5 +30,5 @@ export declare class $Data extends $BaseConverter<$DataUnit> {
30
30
  * @param options Formatting options.
31
31
  * @returns Formatted string like "256MB", "256 megabytes", or "2.56e+2 MB".
32
32
  */
33
- formatTo(target: $DataUnit, options?: ConverterFormatOptions): string;
33
+ formatTo(target: $DataUnit, options?: FormatToOptions): string;
34
34
  }
@@ -1,7 +1,7 @@
1
1
  import type { $Record } from '../object/types';
2
2
  import type { Numeric } from '../types/index';
3
3
  import { $BaseConverter } from './base';
4
- import type { $LengthUnit, ConverterFormatOptions } from './types';
4
+ import type { $LengthUnit, FormatToOptions } from './types';
5
5
  /**
6
6
  * @class LengthConverter
7
7
  * @description Handles conversions with smart `.to()`, `.toAll()`, and `.formatTo()`.
@@ -30,5 +30,5 @@ export declare class $Length extends $BaseConverter<$LengthUnit> {
30
30
  * @param options Formatting options.
31
31
  * @returns Formatted string like "5km", "5.12 miles", or "5e+3 meter".
32
32
  */
33
- formatTo(target: $LengthUnit, options?: ConverterFormatOptions): string;
33
+ formatTo(target: $LengthUnit, options?: FormatToOptions): string;
34
34
  }
@@ -1,7 +1,7 @@
1
1
  import type { $Record } from '../object/types';
2
2
  import type { Numeric } from '../types/index';
3
3
  import { $BaseConverter } from './base';
4
- import type { $MassUnit, ConverterFormatOptions } from './types';
4
+ import type { $MassUnit, FormatToOptions } from './types';
5
5
  /**
6
6
  * @class MassConverter
7
7
  * @description Handles conversions with smart `.to()`, `.toAll()`, and `.formatTo()`.
@@ -30,5 +30,5 @@ export declare class $Mass extends $BaseConverter<$MassUnit> {
30
30
  * @param options Formatting options.
31
31
  * @returns Formatted string like "5kg", "5.25 kilograms", or "5e+3 gram".
32
32
  */
33
- formatTo(target: $MassUnit, options?: ConverterFormatOptions): string;
33
+ formatTo(target: $MassUnit, options?: FormatToOptions): string;
34
34
  }
@@ -1,7 +1,7 @@
1
1
  import type { $Record } from '../object/types';
2
2
  import type { Numeric } from '../types/index';
3
3
  import { $BaseConverter } from './base';
4
- import type { $TempUnit, ConverterFormatOptions } from './types';
4
+ import type { $TempUnit, FormatToOptions } from './types';
5
5
  /**
6
6
  * @class TemperatureConverter
7
7
  * @description Handles conversions with smart `.to()`, `.toAll()`, and `.formatTo()`.
@@ -30,5 +30,5 @@ export declare class $Temperature extends $BaseConverter<$TempUnit> {
30
30
  * @param options Formatting options.
31
31
  * @returns Formatted string like "95°F", "5.25 kelvins", or "5e+3 celsius".
32
32
  */
33
- formatTo(target: $TempUnit, options?: ConverterFormatOptions): string;
33
+ formatTo(target: $TempUnit, options?: FormatToOptions): string;
34
34
  }
@@ -1,7 +1,7 @@
1
1
  import type { $Record } from '../object/types';
2
2
  import type { Numeric } from '../types/index';
3
3
  import { $BaseConverter } from './base';
4
- import type { $TimeUnit, ConverterFormatOptions } from './types';
4
+ import type { $TimeUnit, FormatToOptions } from './types';
5
5
  /**
6
6
  * @class TimeConverter
7
7
  * @description Handles conversions with smart `.to()`, `.toAll()`, and `.formatTo()`.
@@ -30,5 +30,5 @@ export declare class $Time extends $BaseConverter<$TimeUnit> {
30
30
  * @param options Formatting options.
31
31
  * @returns Formatted string like "5h", "5.25 hours", or "5e+3 minute".
32
32
  */
33
- formatTo(target: $TimeUnit, options?: ConverterFormatOptions): string;
33
+ formatTo(target: $TimeUnit, options?: FormatToOptions): string;
34
34
  }
@@ -9,25 +9,27 @@ 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 Units = typeof UNITS;
12
+ type UnitsRecord = typeof UNITS;
13
13
  /** * Category of units supported by the converter. */
14
- export type Category = keyof Units;
14
+ export type Category = keyof UnitsRecord;
15
15
  /** * Map of unit categories to their respective units. */
16
16
  export type UnitMap = {
17
- [Key in Category]: Units[Key][number];
17
+ [Key in Category]: UnitsRecord[Key][number];
18
18
  };
19
19
  /** * Union type of all supported units. May include any other strings. */
20
20
  export type $Unit = LooseLiteral<UnitMap[Category]>;
21
+ /** * Type for array of all Units */
22
+ export type Units = Array<UnitMap[Category]>;
21
23
  /** * Infer the category of a given unit type `U`. */
22
24
  export type InferCategory<U extends $Unit> = {
23
25
  [K in Category]: U extends UnitMap[K] ? K : never;
24
26
  }[Category];
25
- /** Infer Units belong to a specific Category */
27
+ /** * Infer Units belong to a specific Category */
26
28
  export type CategoryUnits<Cat extends Category> = UnitMap[Cat];
27
29
  /** * Type for the returned converter instance based on the provided unit `U`. */
28
30
  export type Converted<U extends $Unit> = InferCategory<U> extends never ? $BaseConverter<U> : InferCategory<U> extends 'area' ? $Area : InferCategory<U> extends 'time' ? $Time : InferCategory<U> extends 'length' ? $Length : InferCategory<U> extends 'mass' ? $Mass : InferCategory<U> extends 'data' ? $Data : InferCategory<U> extends 'temp' ? $Temperature : InferCategory<U> extends 'volume' ? $Volume : $BaseConverter<U>;
29
- /** * Options for formatting converted values. */
30
- export type ConverterFormatOptions = {
31
+ /** * Options for formatting converted values for unit converter method(s). */
32
+ export type FormatToOptions = {
31
33
  /** Style of formatting. Default is `'plural'`. */
32
34
  style?: 'compact' | 'scientific' | 'plural';
33
35
  /** Number of decimal places to include. Default is `2`. */
@@ -1,7 +1,7 @@
1
1
  import type { $Record } from '../object/types';
2
2
  import type { Numeric } from '../types/index';
3
3
  import { $BaseConverter } from './base';
4
- import type { $VolumeUnit, ConverterFormatOptions } from './types';
4
+ import type { $VolumeUnit, FormatToOptions } from './types';
5
5
  /**
6
6
  * @class VolumeConverter
7
7
  * @description Handles conversions with smart `.to()`, `.toAll()`, and `.formatTo()`.
@@ -30,5 +30,5 @@ export declare class $Volume extends $BaseConverter<$VolumeUnit> {
30
30
  * @param options Formatting options.
31
31
  * @returns Formatted string like "5m³", "5.25 cubic-meters", or "5e+3 meter".
32
32
  */
33
- formatTo(target: $VolumeUnit, options?: ConverterFormatOptions): string;
33
+ formatTo(target: $VolumeUnit, options?: FormatToOptions): string;
34
34
  }
@@ -197,7 +197,7 @@ export type UTCMinute = '00' | '15' | '30' | '45';
197
197
  export type $UTCOffset = `${PositiveUTCHour | NegativeUTCHour}:${UTCMinute}`;
198
198
  /** UTC offset in `UTC±HH:mm` format */
199
199
  export type UTCOffSet = `UTC${$UTCOffset}`;
200
- /** Chronos Date Format options */
200
+ /** `Chronos` Date Format options */
201
201
  export interface FormatOptions {
202
202
  /** - The desired format (Default format is dd, `MMM DD, YYYY HH:mm:ss` = `Sun, Apr 06, 2025 16:11:55). */
203
203
  format?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nhb-toolbox",
3
- "version": "4.23.11",
3
+ "version": "4.23.20",
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",
@@ -124,6 +124,11 @@
124
124
  "import": "./dist/esm/date/Chronos.js",
125
125
  "require": "./dist/cjs/date/Chronos.js"
126
126
  },
127
+ "./color": {
128
+ "types": "./dist/dts/colors/Color.d.ts",
129
+ "import": "./dist/esm/colors/Color.js",
130
+ "require": "./dist/cjs/colors/Color.js"
131
+ },
127
132
  "./converter": {
128
133
  "types": "./dist/dts/converter/Converter.d.ts",
129
134
  "import": "./dist/esm/converter/Converter.js",
@@ -259,6 +264,9 @@
259
264
  "chronos": [
260
265
  "dist/dts/date/Chronos.d.ts"
261
266
  ],
267
+ "color": [
268
+ "dist/dts/colors/Color.d.ts"
269
+ ],
262
270
  "converter": [
263
271
  "dist/dts/converter/Converter.d.ts"
264
272
  ],