nhb-toolbox 4.20.50 → 4.20.52

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
@@ -6,6 +6,11 @@ All notable changes to the package will be documented here.
6
6
 
7
7
  ---
8
8
 
9
+ ## [4.20.52] - 2025-09-26
10
+
11
+ - **Added** new `Chronos` _plugin_ `greetingPlugin` for accessing `getGreeting` method in `Chronos` instances.
12
+ - **Fixed** some _docs and internal type related issues_ in `convertObjectValues` utility.
13
+
9
14
  ## [4.20.50] - 2025-09-25
10
15
 
11
16
  - **Fixed** _return type_ of `convertObjectValues` utility to correctly reflect the _transformed object structure_ and `keys` option is now _more strict_: **only accepts keys which values are string and/or number** and **the array cannot be left empty**.
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.greetingPlugin = void 0;
4
+ const greet_1 = require("../greet");
5
+ const greetingPlugin = (ChronosClass) => {
6
+ ChronosClass.prototype.getGreeting = function (configs) {
7
+ const currentTime = this.formatStrict('HH:mm');
8
+ return (0, greet_1.getGreeting)({ currentTime, ...configs });
9
+ };
10
+ };
11
+ exports.greetingPlugin = greetingPlugin;
@@ -46,7 +46,7 @@ function convertObjectValues(data, options) {
46
46
  return newObj;
47
47
  };
48
48
  if (Array.isArray(data)) {
49
- return data?.map((d) => _convertValue(d));
49
+ return data?.map(_convertValue);
50
50
  }
51
51
  return _convertValue(data);
52
52
  }
@@ -181,7 +181,7 @@ export declare class Chronos {
181
181
  * @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
182
182
  * @param options An object that contains one or more properties that specify comparison options.
183
183
  */
184
- toLocaleString(locale?: LocaleCode | Intl.Locale | (LocaleCode | Intl.Locale)[], options?: Intl.DateTimeFormatOptions): string;
184
+ toLocaleString(locale?: LocaleCode | Intl.Locale | Array<LocaleCode | Intl.Locale>, options?: Intl.DateTimeFormatOptions): string;
185
185
  /** @instance Returns the time value in milliseconds since midnight, January 1, 1970 UTC. */
186
186
  getTimeStamp(): number;
187
187
  /**
@@ -0,0 +1,18 @@
1
+ import type { GreetingConfigs } from '../types';
2
+ type MainChronos = typeof import('../Chronos').Chronos;
3
+ declare module '../Chronos' {
4
+ interface Chronos {
5
+ /**
6
+ * @instance Returns a greeting message based on current instance of `Chronos` time or provided time in the `configs`.
7
+ *
8
+ * @remarks This method internally uses {@link https://toolbox.nazmul-nhb.dev/docs/utilities/date/getGreeting getGreeting} function.
9
+ *
10
+ * @param configs - Configuration options for greeting times and messages.
11
+ * @returns The appropriate greeting message.
12
+ */
13
+ getGreeting(configs?: GreetingConfigs): string;
14
+ }
15
+ }
16
+ /** * Plugin to inject `getGreeting` method */
17
+ export declare const greetingPlugin: (ChronosClass: MainChronos) => void;
18
+ export {};
@@ -107,6 +107,7 @@ export interface SanitizeOptions<T> {
107
107
  */
108
108
  requiredKeys?: '*' | DotNotationKey<T>[];
109
109
  }
110
+ /** Options for `convertObjectValues` utility */
110
111
  export interface ConvertObjectOptions<T extends GenericObject, Key extends NumericDotKey<T>, C extends 'string' | 'number'> {
111
112
  /** Array of keys (properties) to convert to `number` or `string` */
112
113
  keys: ValidArray<Key>;
@@ -283,9 +283,10 @@ export type OneOf<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
283
283
  * @template T - The type to test.
284
284
  *
285
285
  * @example
286
- * type A = IsStrictObject<{}>; // true
286
+ * type A = IsStrictObject<{}>; // false
287
287
  * type B = IsStrictObject<() => void>; // false
288
288
  * type C = IsStrictObject<string>; // false
289
+ * type D = IsStrictObject<{name: string}>; // true
289
290
  */
290
291
  export type IsStrictObject<T> = T extends object ? T extends AdvancedTypes ? false : T extends Array<unknown> ? false : true : false;
291
292
  /**
@@ -0,0 +1,7 @@
1
+ import { getGreeting } from '../greet.js';
2
+ export const greetingPlugin = (ChronosClass) => {
3
+ ChronosClass.prototype.getGreeting = function (configs) {
4
+ const currentTime = this.formatStrict('HH:mm');
5
+ return getGreeting({ currentTime, ...configs });
6
+ };
7
+ };
@@ -39,7 +39,7 @@ export function convertObjectValues(data, options) {
39
39
  return newObj;
40
40
  };
41
41
  if (Array.isArray(data)) {
42
- return data?.map((d) => _convertValue(d));
42
+ return data?.map(_convertValue);
43
43
  }
44
44
  return _convertValue(data);
45
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nhb-toolbox",
3
- "version": "4.20.50",
3
+ "version": "4.20.52",
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",
@@ -187,6 +187,11 @@
187
187
  "import": "./dist/esm/date/plugins/fromNowPlugin.js",
188
188
  "require": "./dist/cjs/date/plugins/fromNowPlugin.js"
189
189
  },
190
+ "./plugins/greetingPlugin": {
191
+ "types": "./dist/dts/date/plugins/greetingPlugin.d.ts",
192
+ "import": "./dist/esm/date/plugins/greetingPlugin.js",
193
+ "require": "./dist/cjs/date/plugins/greetingPlugin.js"
194
+ },
190
195
  "./plugins/palindromePlugin": {
191
196
  "types": "./dist/dts/date/plugins/palindromePlugin.d.ts",
192
197
  "import": "./dist/esm/date/plugins/palindromePlugin.js",
@@ -269,6 +274,9 @@
269
274
  "plugins/fromNowPlugin": [
270
275
  "dist/dts/date/plugins/fromNowPlugin.d.ts"
271
276
  ],
277
+ "plugins/greetingPlugin": [
278
+ "dist/dts/date/plugins/greetingPlugin.d.ts"
279
+ ],
272
280
  "plugins/palindromePlugin": [
273
281
  "dist/dts/date/plugins/palindromePlugin.d.ts"
274
282
  ],