nhb-toolbox 4.28.54 → 4.28.57

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,15 @@
4
4
 
5
5
  All notable changes to the package will be documented here.
6
6
 
7
+ ## [4.28.57] - 2026-01-07
8
+
9
+ - **Enhanced** `Color.isLightColor` with an *optional brightness threshold* for custom light/dark detection.
10
+ - **Refined** `TSDoc` to *improve* **IDE IntelliSense** for selected methods in `Color` and `Stylog`.
11
+
12
+ ## [4.28.56] - 2026-01-05
13
+
14
+ - **Resolved** an *issue affecting the conversion of Gregorian date strings to Bangla dates* in `BanglaCalendar`.
15
+
7
16
  ## [4.28.54] - 2026-01-02
8
17
 
9
18
  - **Optimized** `Color.applyOpacity` and **updated** its behavior to return a *new* `Color` instance instead of mutating the original.
@@ -18,17 +18,18 @@ class Color {
18
18
  hsla;
19
19
  constructor(color) {
20
20
  if (color) {
21
- if (_a.isCSSColor(color)) {
22
- const newColor = new _a(css_colors_1.CSS_COLORS[color?.trim()]);
23
- this.hex = newColor.hex;
24
- this.hex8 = newColor.hex8;
25
- this.rgb = newColor.rgb;
26
- this.rgba = newColor.rgba;
27
- this.hsl = newColor.hsl;
28
- this.hsla = newColor.hsla;
21
+ const $color = color.trim();
22
+ if (_a.isCSSColor($color)) {
23
+ const { hex, hex8, rgb, rgba, hsl, hsla } = new _a(css_colors_1.CSS_COLORS[$color]);
24
+ this.hex = hex;
25
+ this.hex8 = hex8;
26
+ this.rgb = rgb;
27
+ this.rgba = rgba;
28
+ this.hsl = hsl;
29
+ this.hsla = hsla;
29
30
  }
30
31
  else {
31
- const colors = this.#convertColorToOthers(color?.trim());
32
+ const colors = this.#convertColorToOthers($color);
32
33
  if ('hex8' in colors) {
33
34
  const [r, g, b] = (0, utils_1.extractAlphaColorValues)(colors.rgba);
34
35
  const [h, s, l] = (0, utils_1.extractAlphaColorValues)(colors.hsla);
@@ -40,28 +41,24 @@ class Color {
40
41
  this.hsla = colors.hsla;
41
42
  }
42
43
  else {
43
- const [r, g, b] = (0, utils_1.extractSolidColorValues)(colors.rgb);
44
- const [h, s, l] = (0, utils_1.extractSolidColorValues)(colors.hsl);
45
44
  this.hex = colors.hex.toUpperCase();
46
- this.hex8 = `${colors.hex.toUpperCase()}${(0, helpers_1._percentToHex)(100)}`;
45
+ this.hex8 = this.#hex6ToHex8(colors.hex);
47
46
  this.rgb = colors.rgb;
48
- this.rgba = `rgba(${r}, ${g}, ${b}, 1)`;
47
+ this.rgba = this.#rgbToRGBA(colors.rgb);
49
48
  this.hsl = colors.hsl;
50
- this.hsla = `hsla(${h}, ${s}%, ${l}%, 1)`;
49
+ this.hsla = this.#hslToHSLA(colors.hsl);
51
50
  }
52
51
  }
53
52
  }
54
53
  else {
55
54
  const hsl = (0, random_1.generateRandomHSLColor)();
56
55
  const { hex, rgb } = (0, convert_1.convertColorCode)(hsl);
57
- const [r, g, b] = (0, utils_1.extractSolidColorValues)(rgb);
58
- const [h, s, l] = (0, utils_1.extractSolidColorValues)(hsl);
59
56
  this.hex = hex.toUpperCase();
60
- this.hex8 = `${hex.toUpperCase()}${(0, helpers_1._percentToHex)(100)}`;
57
+ this.hex8 = this.#hex6ToHex8(hex);
61
58
  this.rgb = rgb;
62
- this.rgba = `rgba(${r}, ${g}, ${b}, 1)`;
59
+ this.rgba = this.#rgbToRGBA(rgb);
63
60
  this.hsl = hsl;
64
- this.hsla = `hsla(${h}, ${s}%, ${l}%, 1)`;
61
+ this.hsla = this.#hslToHSLA(hsl);
65
62
  }
66
63
  }
67
64
  *[Symbol.iterator]() {
@@ -72,6 +69,17 @@ class Color {
72
69
  yield this.hsl;
73
70
  yield this.hsla;
74
71
  }
72
+ #hex6ToHex8(hex) {
73
+ return `${hex.toUpperCase()}${(0, helpers_1._percentToHex)(100)}`;
74
+ }
75
+ #rgbToRGBA(rgb) {
76
+ const [r, g, b] = (0, utils_1.extractSolidColorValues)(rgb);
77
+ return `rgba(${r}, ${g}, ${b}, 1)`;
78
+ }
79
+ #hslToHSLA(hsl) {
80
+ const [h, s, l] = (0, utils_1.extractSolidColorValues)(hsl);
81
+ return `hsla(${h}, ${s}%, ${l}%, 1)`;
82
+ }
75
83
  applyOpacity(opacity) {
76
84
  const hex8 = `${this.hex.slice(0, 7)}${(0, helpers_1._percentToHex)(opacity)}`.toUpperCase();
77
85
  return new _a(hex8);
@@ -168,10 +176,10 @@ class Color {
168
176
  return 'AA';
169
177
  return 'Fail';
170
178
  }
171
- isLightColor() {
179
+ isLightColor(threshold = 127.5) {
172
180
  const [r, g, b] = (0, utils_1.extractSolidColorValues)(this.rgb);
173
181
  const brightness = (r * 299 + g * 587 + b * 114) / 1000;
174
- return brightness > 127.5;
182
+ return brightness > Math.min(255, Math.max(0, threshold));
175
183
  }
176
184
  static isHex6(color) {
177
185
  return /^#[0-9A-Fa-f]{6}$/.test(color?.trim());
@@ -212,7 +212,7 @@ class BanglaCalendar {
212
212
  return (0, helpers_1._formatDateCore)(format || 'ddd, DD mmmm (SS), YYYY বঙ্গাব্দ', dateComponents);
213
213
  }
214
214
  #processGregYear(bnYear, bnMonth) {
215
- const baseGregYear = bnYear ?? this.year.en + constants_1.BN_YEAR_OFFSET;
215
+ const baseGregYear = (bnYear ?? this.year.en) + constants_1.BN_YEAR_OFFSET;
216
216
  const gregYear = (bnMonth ?? this.month.en) > 10 ? baseGregYear + 1 : baseGregYear;
217
217
  return { baseGregYear, gregYear };
218
218
  }
@@ -3,8 +3,8 @@ import type { Maybe, OwnKeys } from '../types/index';
3
3
  import type { FindOptions } from './types';
4
4
  type KeySelector<T> = Extract<OwnKeys<T>, string | number> | ((item: T) => string | number);
5
5
  /**
6
- * The `Finder` class performs optimized searching on arrays.
7
- * It supports binary search, fuzzy search, and smart caching with TTL.
6
+ * @class `Finder` performs optimized searching on arrays.
7
+ * - It supports binary search, fuzzy search, and smart caching with TTL.
8
8
  */
9
9
  export declare class Finder<T extends GenericObject> {
10
10
  #private;
@@ -1,7 +1,7 @@
1
1
  import type { Percent } from '../number/types';
2
2
  import type { Analogous, ColorType, CSSColor, Hex6, Hex8, HSL, HSLA, RGB, RGBA, Tetrad, Triad } from './types';
3
3
  /**
4
- * * Represents a color in {@link Hex6 Hex}, {@link Hex8}, {@link RGB}, {@link RGBA}, {@link HSL}, and {@link HSLA} formats.
4
+ * @class Represents a color in {@link Hex6 Hex}, {@link Hex8}, {@link RGB}, {@link RGBA}, {@link HSL}, and {@link HSLA} formats.
5
5
  *
6
6
  * @remarks
7
7
  * - Instance methods allow transforming, adjusting, and deriving new colors.
@@ -85,12 +85,12 @@ export declare class Color {
85
85
  */
86
86
  constructor(color: ColorType);
87
87
  /**
88
- * * Creates a new `Color` instance using a standard (CSS) named color and automatically converts it to all other supported formats: `Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, and `HSLA`.
88
+ * * Creates a new `Color` instance using a standard (CSS) named color and automatically converts it to all other supported formats: {@link Hex6 Hex}, {@link Hex8}, {@link RGB}, {@link RGBA}, {@link HSL}, and {@link HSLA}.
89
89
  *
90
90
  * @description
91
- * This allows you to use any valid named color from standard `150+ `CSS color names (e.g., `"red"`, `"blue"`, `"rebeccapurple"`)
91
+ * This allows you to use any valid named color from standard `150+` CSS color names (e.g., `"red"`, `"blue"`, `"rebeccapurple"`)
92
92
  *
93
- * @param color - A named color string from standard `150+ `CSS color names ({@link CSSColor}).
93
+ * @param color - A named color string from standard `150+` CSS color names ({@link CSSColor}).
94
94
  *
95
95
  * @remarks
96
96
  * - Instance methods allow transforming, adjusting, and deriving new colors.
@@ -124,7 +124,7 @@ export declare class Color {
124
124
  * - Instance methods allow transforming, adjusting, and deriving new colors.
125
125
  * - Static methods provide format validation and type-guard–style checks for supported color representations.
126
126
  *
127
- * @param color - An optional input color string in any supported format (`Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, or `HSLA`) or a named color string from standard `150+ `CSS color names ({@link CSSColor}) to convert in all other (includes the current format) formats.
127
+ * @param color - An optional input color string in any supported format (`Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, or `HSLA`) or a named color string from standard `150+` CSS color names ({@link CSSColor}) to convert in all other (includes the current format) formats.
128
128
  *
129
129
  * @example
130
130
  * // Convert an existing Hex color to all other formats
@@ -266,9 +266,11 @@ export declare class Color {
266
266
  getWCAGRating(other: ColorType | CSSColor): 'Fail' | 'AA' | 'AAA';
267
267
  /**
268
268
  * @instance Determines if the color is light based on its perceived brightness.
269
+ * @param threshold Optional brightness threshold (`0–255`). Defaults to `127.5`.
270
+ * @remarks The brightness {@link threshold} is clamped to the valid *RGB range* (`0–255`) to prevent invalid comparisons.
269
271
  * @returns `true` if light, `false` if dark.
270
272
  */
271
- isLightColor(): boolean;
273
+ isLightColor(threshold?: number): boolean;
272
274
  /**
273
275
  * @static Checks if a color is in {@link Hex6} format.
274
276
  *
@@ -14,7 +14,7 @@ export type Hex = `#${string}`;
14
14
  * * Represents a hexadecimal color code.
15
15
  * * Format: `#3C6945`
16
16
  */
17
- export type Hex6 = Branded<`#${string}`, 'Hex6'>;
17
+ export type Hex6 = Branded<Hex, 'Hex6'>;
18
18
  /**
19
19
  * * Represents an RGB color string.
20
20
  * * Format: `rgb(R, G, B)`
@@ -37,7 +37,7 @@ export type HSL = `hsl(${number}, ${number}%, ${number}%)` | `hsl(${number},${nu
37
37
  * * Represents a hexadecimal color code with optional alpha channel.
38
38
  * * Format: `#3C6945FF`
39
39
  */
40
- export type Hex8 = Branded<`#${string}`, 'Hex8'>;
40
+ export type Hex8 = Branded<Hex, 'Hex8'>;
41
41
  /**
42
42
  * * Represents an RGBA color string, now includes optional alpha (opacity).
43
43
  * * Format: `rgba(R, G, B, A)`
@@ -1,10 +1,9 @@
1
1
  import type { Enumerate, NumberRange } from '../number/types';
2
2
  import type { $BnEn, BanglaDate, BanglaDateFormat, BanglaDayName, BanglaMonth, BanglaMonthName, BanglaSeasonName, BanglaYear, BnCalendarConfig, BnCalendarVariant } from './types';
3
3
  /**
4
- * * Represents a date in the Bangla calendar system with support for different variants.
5
- *
6
- * - This class provides functionality to create, manipulate, and convert dates between the Bangla and Gregorian calendar systems.
7
- * - It supports two calendar variants: `'revised-2019'` (default) and `'revised-1966'`.
4
+ * @class Represents a date in the Bangla calendar system with support for different variants.
5
+ * - This class provides functionality to create, manipulate, convert dates between the Bangla and Gregorian calendar systems.
6
+ * - It supports two Bangla calendar variants: `'revised-2019'` (default) and `'revised-1966'`.
8
7
  *
9
8
  * @example
10
9
  * // Create from current date
@@ -3,10 +3,9 @@ import type { LooseLiteral, TupleOf } from '../utils/types';
3
3
  import { INTERNALS } from './constants';
4
4
  import type { $NativeTzNameOrId, $TimeZoneIdentifier, $UTCOffset, ChronosInput, ChronosInternals, ChronosMethods, ChronosObject, ChronosPlugin, ChronosWithOptions, DateRangeOptions, DateTimeFormatOptions, FormatOptions, LocalesArguments, Milliseconds, MonthName, Quarter, RangeWithDates, RelativeDateRange, RelativeRangeOptions, StrictFormat, TimeOnlyFormat, TimeUnit, TimeUnitValue, TimeZone, TimeZoneId, TimeZoneIdNative, TimeZoneName, UTCOffset, WeekDay } from './types';
5
5
  /**
6
- * * Creates a new immutable `Chronos` instance.
7
- *
8
- * **Note**:
9
- * - *If a date is provided **without a time component**, the instance will default to `00:00:00.000` UTC and convert it to the **equivalent local time** using the current environment's UTC offset.*
6
+ * @class Creates a new immutable `Chronos` instance.
7
+ * - **Note**: *If a date is provided **without a time component**, the instance will default to `00:00:00.000` UTC
8
+ * and convert it to the **equivalent local time** using the current environment's UTC offset.*
10
9
  *
11
10
  * @param value - A date value (`number`, `string`, `Date`, or `Chronos` object).
12
11
  *
@@ -1,6 +1,6 @@
1
1
  /**
2
- * * Lightweight stream-cipher–style encryption utility using `HMAC-SHA256` for keystream generation and authentication.
3
- * - The class derives separate encryption and MAC keys from the provided secret.
2
+ * @class Lightweight stream-cipher–style encryption utility using `HMAC-SHA256` for keystream generation and authentication.
3
+ * - The class derives separate encryption and MAC keys from the provided secret.
4
4
  *
5
5
  * @remarks
6
6
  * - **The encryption scheme is:**
@@ -2,8 +2,9 @@ import type { GenericObject } from '../object/types';
2
2
  import type { Maybe } from '../types/index';
3
3
  import type { DecodedToken, SignetPayload, SignOptions, TokenString, VerifiedToken, VerifyOptions } from './types';
4
4
  /**
5
- * * A lightweight, secure implementation of JWT-like tokens using `HMAC-SHA256` signatures.
6
- * - This class provides methods to create, verify, and decode tokens with a simple API similar to JSON Web Tokens (`JWT`) but with a smaller footprint and zero dependencies.
5
+ * @class A lightweight, secure implementation of JWT-like tokens using `HMAC-SHA256` signatures.
6
+ * - This class provides methods to create, verify, and decode tokens with a simple API similar to JSON Web Tokens (`JWT`)
7
+ * but with a smaller footprint and zero dependencies.
7
8
  *
8
9
  * @remarks
9
10
  * - **Features:**
@@ -1,7 +1,7 @@
1
1
  import type { Maybe } from '../types/index';
2
2
  import type { HttpStatusCode, HttpStatusName, StatusCategory, StatusCode, StatusEntry, StatusName } from './types';
3
3
  /**
4
- * * Utility class for retrieving and managing HTTP status codes with rich MDN-based metadata.
4
+ * @class Utility class for retrieving and managing HTTP status codes with rich MDN-based metadata.
5
5
  *
6
6
  * @remarks
7
7
  * - Supports lookup by code or name (both `SOME_NAME` and `Some Name` formats).
@@ -1,13 +1,13 @@
1
1
  import type { PluralizeOptions } from './types';
2
2
  /**
3
- * * Handles English word pluralization and singularization with support for irregular forms and uncountable nouns.
3
+ * @class Handles English word pluralization and singularization with support for irregular forms and uncountable nouns.
4
4
  *
5
- * - Provides methods to convert words between singular and plural forms, check if a word is plural or singular, and manage custom pluralization rules.
6
- * - Supports adding custom pluralization and singularization rules, as well as uncountable nouns.
7
- * - Automatically handles common irregular forms like "child" to "children"
8
- * - Automatically loads common irregular forms and uncountable nouns.
9
- * - Supports options for count-based pluralization, allowing for inclusive formatting.
10
- * - This class is useful for applications that need to handle natural language processing, such as chatbots, content management systems, or any text processing tasks that require accurate pluralization.
5
+ * - Provides methods to convert words between singular and plural forms, check if a word is plural or singular, and manage custom pluralization rules.
6
+ * - Supports adding custom pluralization and singularization rules, as well as uncountable nouns.
7
+ * - Automatically handles common irregular forms like "child" to "children"
8
+ * - Automatically loads common irregular forms and uncountable nouns.
9
+ * - Supports options for count-based pluralization, allowing for inclusive formatting.
10
+ * - This class is useful for applications that need to handle natural language processing, such as chatbots, content management systems, or any text processing tasks that require accurate pluralization.
11
11
  *
12
12
  * @remarks
13
13
  * - For simpler pluralization (plural with only 's'), please refer to {@link https://toolbox.nazmul-nhb.dev/docs/utilities/string/formatUnitWithPlural formatUnitWithPlural} instead.
@@ -17,12 +17,11 @@ export type AnsiSequence = [string, string];
17
17
  /**
18
18
  * * Type representing a fully chainable `LogStyler` instance.
19
19
  *
20
- * @remarks - Each property corresponds to a style (foreground color, background color, or text effect) and returns a new `Stylog` instance, allowing fluent chaining like:
21
- *
22
- * **This type combines:**
23
- * - The methods of `LogStyler` (e.g., `.style()`, `.log()`)
24
- * - Dynamically generated properties for all available `Styles`
25
- * that return another `Stylog` instance for chaining.
20
+ * @remarks
21
+ * - Each property corresponds to a style and returns a new `Stylog` instance, allowing fluent chaining.
22
+ * - **This type combines:**
23
+ * - The methods of `LogStyler` (e.g., `.style()`, `.log()`)
24
+ * - Dynamically generated properties for all available `Styles` that return another `Stylog` instance for chaining.
26
25
  *
27
26
  * @example
28
27
  * Stylog.green.bold.bgBlue.log('Hello World');
@@ -60,7 +59,7 @@ export declare function isBGColor(value: string): value is BGColor;
60
59
  /** * Check if a string represent `TextStyle` used in `LogStyler`. */
61
60
  export declare function isTextStyle(value: string): value is TextStyle;
62
61
  /**
63
- * * Utility class for styling console log output with `ANSI` (`Node.js`) or `CSS` (Browser).
62
+ * @class Utility class for styling console log output with `ANSI` (`Node.js`) or `CSS` (Browser).
64
63
  *
65
64
  * @remarks
66
65
  * - Allows chaining of style methods or initializing with predefined styles.
@@ -229,7 +228,7 @@ export declare class LogStyler {
229
228
  /**
230
229
  * * Apply a HEX color to the text foreground.
231
230
  *
232
- * @param code - HEX color string (e.g., '#4682B4' or '4682B4').
231
+ * @param code - HEX color string (e.g., `'#4682B4'` or `'4682B4'`).
233
232
  * @returns A new `StylogChain` instance with the HEX color applied.
234
233
  *
235
234
  * @example
@@ -254,7 +253,7 @@ export declare class LogStyler {
254
253
  /**
255
254
  * * Apply a HEX color to the text background.
256
255
  *
257
- * @param code - HEX color string (e.g., '#4682B4' or '4682B4').
256
+ * @param code - HEX color string (e.g., `'#4682B4'` or `'4682B4'`).
258
257
  * @returns A new StylogChain instance with the HEX background color applied.
259
258
  *
260
259
  * @example
@@ -279,7 +278,7 @@ export declare class LogStyler {
279
278
  /**
280
279
  * * Apply an RGB color to the text foreground using a CSS-like string.
281
280
  *
282
- * @param code - RGB color string (e.g., 'rgb(11, 45, 1)' or '11, 45, 1').
281
+ * @param code - RGB color string (e.g., `'rgb(11, 45, 1)'` or `'11, 45, 1'`).
283
282
  * @returns A new `StylogChain` instance with the RGB color applied.
284
283
  *
285
284
  * @example
@@ -325,7 +324,7 @@ export declare class LogStyler {
325
324
  /**
326
325
  * * Apply an RGB color to the text background using a CSS-like string.
327
326
  *
328
- * @param code - RGB color string (e.g., 'rgb(225, 169, 196)' or '225, 169, 196').
327
+ * @param code - RGB color string (e.g., `'rgb(225, 169, 196)'` or `'225, 169, 196'`).
329
328
  * @returns A new `StylogChain` instance with the RGB background color applied.
330
329
  *
331
330
  * @example
@@ -371,7 +370,7 @@ export declare class LogStyler {
371
370
  /**
372
371
  * * Apply an HSL color to the text foreground using a CSS-like string.
373
372
  *
374
- * @param code - HSL color string (e.g., 'hsl(50 80.5% 40%)').
373
+ * @param code - HSL color string (e.g., `'hsl(50 80.5% 40%)'`).
375
374
  * @returns A new `StylogChain` instance with the HSL color applied.
376
375
  *
377
376
  * @example
@@ -396,9 +395,9 @@ export declare class LogStyler {
396
395
  /**
397
396
  * * Apply an HSL color to the text foreground using individual components.
398
397
  *
399
- * @param hue - Hue component (0-360).
400
- * @param saturation - Saturation component (0-100 or 0-100%).
401
- * @param lightness - Lightness component (0-100 or 0-100%).
398
+ * @param hue - Hue component (`0-360`).
399
+ * @param saturation - Saturation component (`0-100`).
400
+ * @param lightness - Lightness component (`0-100`).
402
401
  * @returns A new `StylogChain` instance with the HSL color applied.
403
402
  *
404
403
  * @example
@@ -417,7 +416,7 @@ export declare class LogStyler {
417
416
  /**
418
417
  * * Apply an HSL color to the text background using a CSS-like string.
419
418
  *
420
- * @param code - HSL color string (e.g., 'hsl(50 80.5% 40%)').
419
+ * @param code - HSL color string (e.g., `'hsl(50 80.5% 40%)'`).
421
420
  * @returns A new `StylogChain` instance with the HSL background color applied.
422
421
  *
423
422
  * @example
@@ -442,9 +441,9 @@ export declare class LogStyler {
442
441
  /**
443
442
  * * Apply an HSL color to the text background using individual components.
444
443
  *
445
- * @param hue - Hue component (0-360).
446
- * @param saturation - Saturation component (0-100 or 0-100%).
447
- * @param lightness - Lightness component (0-100 or 0-100%).
444
+ * @param hue - Hue component (`0-360`).
445
+ * @param saturation - Saturation component (`0-100`).
446
+ * @param lightness - Lightness component (`0-100`).
448
447
  * @returns A new StylogChain instance with the HSL background color applied.
449
448
  *
450
449
  * @example
@@ -1,5 +1,5 @@
1
1
  import type { FromMetaOptions, PageListOptions, PaginatorMeta, PaginatorOptions } from './types';
2
- /** * Generates pagination logic, offsets, metadata and other pagination logic(s) for APIs and UIs. */
2
+ /** @class Generates pagination logic, offsets, metadata and other pagination logic(s) for APIs and UIs. */
3
3
  export declare class Paginator {
4
4
  #private;
5
5
  /**
@@ -1,12 +1,12 @@
1
1
  /**
2
- * * Handles English verb conjugation between base, past tense, and past participle forms.
2
+ * @class Handles English verb conjugation between base, past tense, and past participle forms.
3
3
  *
4
- * - Provides methods to convert verbs between base, past, and past participle forms, check verb forms, and manage custom conjugation rules.
5
- * - Supports adding custom conjugation rules and irregular verbs.
6
- * - Automatically handles common irregular verbs like "go" to "went" (past) and "gone" (past participle).
7
- * - Automatically loads common irregular verbs and conjugation rules.
8
- * - Preserves case sensitivity of input verbs.
9
- * - This class is useful for natural language processing tasks, such as chatbots, text analysis, or content generation systems requiring accurate verb conjugation.
4
+ * - Provides methods to convert verbs between base, past, and past participle forms, check verb forms, and manage custom conjugation rules.
5
+ * - Supports adding custom conjugation rules and irregular verbs.
6
+ * - Automatically handles common irregular verbs like "go" to "went" (past) and "gone" (past participle).
7
+ * - Automatically loads common irregular verbs and conjugation rules.
8
+ * - Preserves case sensitivity of input verbs.
9
+ * - This class is useful for natural language processing tasks, such as chatbots, text analysis, or content generation systems requiring accurate verb conjugation.
10
10
  *
11
11
  * @remarks
12
12
  * For ready to use instance, please refer to {@link https://toolbox.nazmul-nhb.dev/docs/utilities/string/verbalizer verbalizer} instead.
@@ -15,17 +15,18 @@ export class Color {
15
15
  hsla;
16
16
  constructor(color) {
17
17
  if (color) {
18
- if (_a.isCSSColor(color)) {
19
- const newColor = new _a(CSS_COLORS[color?.trim()]);
20
- this.hex = newColor.hex;
21
- this.hex8 = newColor.hex8;
22
- this.rgb = newColor.rgb;
23
- this.rgba = newColor.rgba;
24
- this.hsl = newColor.hsl;
25
- this.hsla = newColor.hsla;
18
+ const $color = color.trim();
19
+ if (_a.isCSSColor($color)) {
20
+ const { hex, hex8, rgb, rgba, hsl, hsla } = new _a(CSS_COLORS[$color]);
21
+ this.hex = hex;
22
+ this.hex8 = hex8;
23
+ this.rgb = rgb;
24
+ this.rgba = rgba;
25
+ this.hsl = hsl;
26
+ this.hsla = hsla;
26
27
  }
27
28
  else {
28
- const colors = this.#convertColorToOthers(color?.trim());
29
+ const colors = this.#convertColorToOthers($color);
29
30
  if ('hex8' in colors) {
30
31
  const [r, g, b] = extractAlphaColorValues(colors.rgba);
31
32
  const [h, s, l] = extractAlphaColorValues(colors.hsla);
@@ -37,28 +38,24 @@ export class Color {
37
38
  this.hsla = colors.hsla;
38
39
  }
39
40
  else {
40
- const [r, g, b] = extractSolidColorValues(colors.rgb);
41
- const [h, s, l] = extractSolidColorValues(colors.hsl);
42
41
  this.hex = colors.hex.toUpperCase();
43
- this.hex8 = `${colors.hex.toUpperCase()}${_percentToHex(100)}`;
42
+ this.hex8 = this.#hex6ToHex8(colors.hex);
44
43
  this.rgb = colors.rgb;
45
- this.rgba = `rgba(${r}, ${g}, ${b}, 1)`;
44
+ this.rgba = this.#rgbToRGBA(colors.rgb);
46
45
  this.hsl = colors.hsl;
47
- this.hsla = `hsla(${h}, ${s}%, ${l}%, 1)`;
46
+ this.hsla = this.#hslToHSLA(colors.hsl);
48
47
  }
49
48
  }
50
49
  }
51
50
  else {
52
51
  const hsl = generateRandomHSLColor();
53
52
  const { hex, rgb } = convertColorCode(hsl);
54
- const [r, g, b] = extractSolidColorValues(rgb);
55
- const [h, s, l] = extractSolidColorValues(hsl);
56
53
  this.hex = hex.toUpperCase();
57
- this.hex8 = `${hex.toUpperCase()}${_percentToHex(100)}`;
54
+ this.hex8 = this.#hex6ToHex8(hex);
58
55
  this.rgb = rgb;
59
- this.rgba = `rgba(${r}, ${g}, ${b}, 1)`;
56
+ this.rgba = this.#rgbToRGBA(rgb);
60
57
  this.hsl = hsl;
61
- this.hsla = `hsla(${h}, ${s}%, ${l}%, 1)`;
58
+ this.hsla = this.#hslToHSLA(hsl);
62
59
  }
63
60
  }
64
61
  *[Symbol.iterator]() {
@@ -69,6 +66,17 @@ export class Color {
69
66
  yield this.hsl;
70
67
  yield this.hsla;
71
68
  }
69
+ #hex6ToHex8(hex) {
70
+ return `${hex.toUpperCase()}${_percentToHex(100)}`;
71
+ }
72
+ #rgbToRGBA(rgb) {
73
+ const [r, g, b] = extractSolidColorValues(rgb);
74
+ return `rgba(${r}, ${g}, ${b}, 1)`;
75
+ }
76
+ #hslToHSLA(hsl) {
77
+ const [h, s, l] = extractSolidColorValues(hsl);
78
+ return `hsla(${h}, ${s}%, ${l}%, 1)`;
79
+ }
72
80
  applyOpacity(opacity) {
73
81
  const hex8 = `${this.hex.slice(0, 7)}${_percentToHex(opacity)}`.toUpperCase();
74
82
  return new _a(hex8);
@@ -165,10 +173,10 @@ export class Color {
165
173
  return 'AA';
166
174
  return 'Fail';
167
175
  }
168
- isLightColor() {
176
+ isLightColor(threshold = 127.5) {
169
177
  const [r, g, b] = extractSolidColorValues(this.rgb);
170
178
  const brightness = (r * 299 + g * 587 + b * 114) / 1000;
171
- return brightness > 127.5;
179
+ return brightness > Math.min(255, Math.max(0, threshold));
172
180
  }
173
181
  static isHex6(color) {
174
182
  return /^#[0-9A-Fa-f]{6}$/.test(color?.trim());
@@ -209,7 +209,7 @@ export class BanglaCalendar {
209
209
  return _formatDateCore(format || 'ddd, DD mmmm (SS), YYYY বঙ্গাব্দ', dateComponents);
210
210
  }
211
211
  #processGregYear(bnYear, bnMonth) {
212
- const baseGregYear = bnYear ?? this.year.en + BN_YEAR_OFFSET;
212
+ const baseGregYear = (bnYear ?? this.year.en) + BN_YEAR_OFFSET;
213
213
  const gregYear = (bnMonth ?? this.month.en) > 10 ? baseGregYear + 1 : baseGregYear;
214
214
  return { baseGregYear, gregYear };
215
215
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nhb-toolbox",
3
- "version": "4.28.54",
3
+ "version": "4.28.57",
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",
@@ -52,7 +52,7 @@
52
52
  "eslint": "^9.39.2",
53
53
  "eslint-config-prettier": "^10.1.8",
54
54
  "eslint-plugin-prettier": "^5.5.4",
55
- "globals": "^16.5.0",
55
+ "globals": "^17.0.0",
56
56
  "husky": "^9.1.7",
57
57
  "jest": "^30.2.0",
58
58
  "lint-staged": "^16.2.7",