nhb-toolbox 4.3.2 → 4.10.3
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/dist/cjs/array/basics.js +2 -1
- package/dist/cjs/number/convert.js +8 -4
- package/dist/dts/array/basics.d.ts +2 -1
- package/dist/dts/array/basics.d.ts.map +1 -1
- package/dist/dts/number/convert.d.ts +3 -2
- package/dist/dts/number/convert.d.ts.map +1 -1
- package/dist/esm/array/basics.js +2 -1
- package/dist/esm/number/convert.js +8 -4
- package/package.json +1 -1
package/dist/cjs/array/basics.js
CHANGED
|
@@ -17,8 +17,9 @@ const flattenArray = (input) => {
|
|
|
17
17
|
};
|
|
18
18
|
exports.flattenArray = flattenArray;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* @deprecated _Please, use `findAll` instance method from `Finder` class for **more advanced filtering and searching.**_
|
|
21
21
|
*
|
|
22
|
+
* * Filters an array of objects based on multiple conditions for specified keys.
|
|
22
23
|
* @param array - The array of objects to filter.
|
|
23
24
|
* @param conditions - An object where keys represent the property names and values represent filter conditions.
|
|
24
25
|
* The conditions can be a function `(value: T[K]) => boolean`.
|
|
@@ -5,13 +5,17 @@ exports.numberToWords = numberToWords;
|
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
const helpers_1 = require("./helpers");
|
|
7
7
|
/**
|
|
8
|
-
* * Converts a
|
|
9
|
-
* @
|
|
8
|
+
* * Converts a numeric value into its corresponding English word representation.
|
|
9
|
+
* @warning ***Supports numeric values up to `10e19` or `10^20` (one hundred quintillion).***
|
|
10
|
+
* @warning ***Decimal values are ignored; only the integer part is converted.***
|
|
10
11
|
* @param number - The number to convert into words.
|
|
11
12
|
* @returns The number converted in words.
|
|
12
13
|
*/
|
|
13
14
|
function numberToWords(num) {
|
|
14
|
-
let number = Number(num);
|
|
15
|
+
let number = Math.trunc(Number(num));
|
|
16
|
+
if (!Number.isFinite(number) || isNaN(number)) {
|
|
17
|
+
return 'Invalid Number!';
|
|
18
|
+
}
|
|
15
19
|
const isNegative = number < 0;
|
|
16
20
|
if (number === 0)
|
|
17
21
|
return 'zero';
|
|
@@ -20,7 +24,7 @@ function numberToWords(num) {
|
|
|
20
24
|
let result = '';
|
|
21
25
|
while (number > 0) {
|
|
22
26
|
if (i >= constants_1.thousands.length) {
|
|
23
|
-
return `Number exceeds supported range (max is
|
|
27
|
+
return `Number exceeds supported range (max is 10e19 aka 10^20)`;
|
|
24
28
|
}
|
|
25
29
|
if (number % 1000 !== 0) {
|
|
26
30
|
const isLastGroup = i === 0 && number % 100 < 100;
|
|
@@ -8,8 +8,9 @@ import type { Flattened } from './types';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const flattenArray: <T>(input: T | T[]) => Flattened<T>[];
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* @deprecated _Please, use `findAll` instance method from `Finder` class for **more advanced filtering and searching.**_
|
|
12
12
|
*
|
|
13
|
+
* * Filters an array of objects based on multiple conditions for specified keys.
|
|
13
14
|
* @param array - The array of objects to filter.
|
|
14
15
|
* @param conditions - An object where keys represent the property names and values represent filter conditions.
|
|
15
16
|
* The conditions can be a function `(value: T[K]) => boolean`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../../src/array/basics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,KAAG,SAAS,CAAC,CAAC,CAAC,EAO5D,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../../src/array/basics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,KAAG,SAAS,CAAC,CAAC,CAAC,EAO5D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,aAAa,SACpD,CAAC,EAAE,cACE,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,OAAO,GAAE,KACnE,CAAC,EAeH,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,CAAC,KAAG,OAWnD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,CAAC,EAAE,KAAG,CAAC,EAW7C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,CAAC,EAAE,KAAG,CAAC,GAAG,SAEvD,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Numeric } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* * Converts a
|
|
4
|
-
* @
|
|
3
|
+
* * Converts a numeric value into its corresponding English word representation.
|
|
4
|
+
* @warning ***Supports numeric values up to `10e19` or `10^20` (one hundred quintillion).***
|
|
5
|
+
* @warning ***Decimal values are ignored; only the integer part is converted.***
|
|
5
6
|
* @param number - The number to convert into words.
|
|
6
7
|
* @returns The number converted in words.
|
|
7
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/number/convert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAIxC
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/number/convert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAIxC;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAoClD;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,QAAS,OAAO,KAAG,MA8BrD,CAAC"}
|
package/dist/esm/array/basics.js
CHANGED
|
@@ -13,8 +13,9 @@ export const flattenArray = (input) => {
|
|
|
13
13
|
}, []);
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* @deprecated _Please, use `findAll` instance method from `Finder` class for **more advanced filtering and searching.**_
|
|
17
17
|
*
|
|
18
|
+
* * Filters an array of objects based on multiple conditions for specified keys.
|
|
18
19
|
* @param array - The array of objects to filter.
|
|
19
20
|
* @param conditions - An object where keys represent the property names and values represent filter conditions.
|
|
20
21
|
* The conditions can be a function `(value: T[K]) => boolean`.
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { thousands } from './constants';
|
|
2
2
|
import { _convertLessThanThousand } from './helpers';
|
|
3
3
|
/**
|
|
4
|
-
* * Converts a
|
|
5
|
-
* @
|
|
4
|
+
* * Converts a numeric value into its corresponding English word representation.
|
|
5
|
+
* @warning ***Supports numeric values up to `10e19` or `10^20` (one hundred quintillion).***
|
|
6
|
+
* @warning ***Decimal values are ignored; only the integer part is converted.***
|
|
6
7
|
* @param number - The number to convert into words.
|
|
7
8
|
* @returns The number converted in words.
|
|
8
9
|
*/
|
|
9
10
|
export function numberToWords(num) {
|
|
10
|
-
let number = Number(num);
|
|
11
|
+
let number = Math.trunc(Number(num));
|
|
12
|
+
if (!Number.isFinite(number) || isNaN(number)) {
|
|
13
|
+
return 'Invalid Number!';
|
|
14
|
+
}
|
|
11
15
|
const isNegative = number < 0;
|
|
12
16
|
if (number === 0)
|
|
13
17
|
return 'zero';
|
|
@@ -16,7 +20,7 @@ export function numberToWords(num) {
|
|
|
16
20
|
let result = '';
|
|
17
21
|
while (number > 0) {
|
|
18
22
|
if (i >= thousands.length) {
|
|
19
|
-
return `Number exceeds supported range (max is
|
|
23
|
+
return `Number exceeds supported range (max is 10e19 aka 10^20)`;
|
|
20
24
|
}
|
|
21
25
|
if (number % 1000 !== 0) {
|
|
22
26
|
const isLastGroup = i === 0 && number % 100 < 100;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "4.3
|
|
3
|
+
"version": "4.10.3",
|
|
4
4
|
"description": "A versatile collection of smart, efficient, and reusable utility functions and classes for everyday development needs.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|