nhb-toolbox 2.3.5 → 2.3.7
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/form/convert.d.ts +2 -2
- package/dist/form/convert.d.ts.map +1 -1
- package/dist/form/convert.js +3 -3
- package/dist/number/basics.d.ts +4 -4
- package/dist/number/basics.d.ts.map +1 -1
- package/dist/number/basics.js +12 -6
- package/dist/number/types.d.ts +4 -2
- package/dist/number/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/form/convert.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export declare const convertIntoFormData: <T extends object>(data: T) => FormDat
|
|
|
8
8
|
/**
|
|
9
9
|
* * Check if a formdata object is empty.
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
12
|
-
* @returns Whether the formdata is empty.
|
|
11
|
+
* @param data FormData to check.
|
|
12
|
+
* @returns Boolean (`true`/`false`) Whether the formdata is empty.
|
|
13
13
|
*/
|
|
14
14
|
export declare const isEmptyFormData: (data: FormData) => boolean;
|
|
15
15
|
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/form/convert.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,MAAM,QAAQ,CAAC,KAAG,QAY/D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,SAAU,QAAQ,KAAG,
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/form/convert.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,MAAM,QAAQ,CAAC,KAAG,QAY/D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,SAAU,QAAQ,KAAG,OAQhD,CAAC"}
|
package/dist/form/convert.js
CHANGED
|
@@ -24,13 +24,13 @@ exports.convertIntoFormData = convertIntoFormData;
|
|
|
24
24
|
/**
|
|
25
25
|
* * Check if a formdata object is empty.
|
|
26
26
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @returns Whether the formdata is empty.
|
|
27
|
+
* @param data FormData to check.
|
|
28
|
+
* @returns Boolean (`true`/`false`) Whether the formdata is empty.
|
|
29
29
|
*/
|
|
30
30
|
const isEmptyFormData = (data) => {
|
|
31
31
|
if ('entries' in data && typeof data.entries === 'function') {
|
|
32
32
|
return Array.from(data.entries()).length === 0;
|
|
33
33
|
}
|
|
34
|
-
throw new Error('`FormData.entries()` is not supported in this environment
|
|
34
|
+
throw new Error('`FormData.entries()` is not supported in this environment!');
|
|
35
35
|
};
|
|
36
36
|
exports.isEmptyFormData = isEmptyFormData;
|
package/dist/number/basics.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DecimalOptions, RandomNumberOptions } from './types';
|
|
1
|
+
import type { ConvertedDecimal, DecimalOptions, RandomNumberOptions } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* * Utility to generate a random number between a given range.
|
|
4
4
|
* * If no options are provided, it will generate a random number between `0` and `100` (inclusive).
|
|
@@ -11,11 +11,11 @@ export declare const getRandomNumber: (options?: RandomNumberOptions) => number;
|
|
|
11
11
|
/**
|
|
12
12
|
* * Utility to round a number to given decimal places.
|
|
13
13
|
*
|
|
14
|
-
* @param
|
|
14
|
+
* @param input - Number or `stringified` number to round.
|
|
15
15
|
* @param options - Options for rounding behavior, including decimal places and return type.
|
|
16
|
-
* @returns Converted number
|
|
16
|
+
* @returns Converted number as `number` (default) or `string` (if `isString` is `true`).
|
|
17
17
|
*/
|
|
18
|
-
export declare const convertToDecimal: (
|
|
18
|
+
export declare const convertToDecimal: <T extends boolean | undefined = false>(input: number | `${number}`, options?: DecimalOptions<T>) => ConvertedDecimal<T>;
|
|
19
19
|
/**
|
|
20
20
|
* * Calculates the HCF/GCD of multiple numbers.
|
|
21
21
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/number/basics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/number/basics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,MAAM,SAAS,CAAC;AAEjB;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,aAAc,mBAAmB,KAAG,MA+C/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,OAAO,GAAG,SAAS,iBACtD,MAAM,GAAG,GAAG,MAAM,EAAE,YACjB,cAAc,CAAC,CAAC,CAAC,KACzB,gBAAgB,CAAC,CAAC,CAcpB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,eAAgB,MAAM,EAAE,KAAG,MAQnD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,eAAgB,MAAM,EAAE,KAAG,MAQnD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,MAAM,UAAW,MAAM,KAAG,OAEtC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,KAAK,UAAW,MAAM,KAAG,OAErC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,UAAW,MAAM,cAAc,MAAM,KAAG,OAE9D,CAAC"}
|
package/dist/number/basics.js
CHANGED
|
@@ -47,16 +47,22 @@ exports.getRandomNumber = getRandomNumber;
|
|
|
47
47
|
/**
|
|
48
48
|
* * Utility to round a number to given decimal places.
|
|
49
49
|
*
|
|
50
|
-
* @param
|
|
50
|
+
* @param input - Number or `stringified` number to round.
|
|
51
51
|
* @param options - Options for rounding behavior, including decimal places and return type.
|
|
52
|
-
* @returns Converted number
|
|
52
|
+
* @returns Converted number as `number` (default) or `string` (if `isString` is `true`).
|
|
53
53
|
*/
|
|
54
|
-
const convertToDecimal = (
|
|
54
|
+
const convertToDecimal = (input, options) => {
|
|
55
55
|
const { decimalPlaces = 2, isString = false } = options || {};
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
let number;
|
|
57
|
+
if (typeof input === 'number') {
|
|
58
|
+
number = input;
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
+
else {
|
|
61
|
+
number = Number(input);
|
|
62
|
+
}
|
|
63
|
+
return isString ?
|
|
64
|
+
number.toFixed(decimalPlaces)
|
|
65
|
+
: Number(number.toFixed(decimalPlaces));
|
|
60
66
|
};
|
|
61
67
|
exports.convertToDecimal = convertToDecimal;
|
|
62
68
|
/**
|
package/dist/number/types.d.ts
CHANGED
|
@@ -10,12 +10,14 @@ export interface RandomNumberOptions {
|
|
|
10
10
|
includeMax?: boolean;
|
|
11
11
|
}
|
|
12
12
|
/** - Decimal options for converting to decimal */
|
|
13
|
-
export interface DecimalOptions {
|
|
13
|
+
export interface DecimalOptions<T extends boolean | undefined = false> {
|
|
14
14
|
/** Number of decimal places to round to. Defaults to `2`. */
|
|
15
15
|
decimalPlaces?: number;
|
|
16
16
|
/** If the return value is in `string` or `number`. Defaults to `false`. */
|
|
17
|
-
isString?:
|
|
17
|
+
isString?: T;
|
|
18
18
|
}
|
|
19
|
+
/** - Converted decimal type either `number` or `string`. */
|
|
20
|
+
export type ConvertedDecimal<T> = T extends true ? string : number;
|
|
19
21
|
/** - Type of numbers to generate */
|
|
20
22
|
export type NumberType = 'any' | 'natural' | 'odd' | 'even' | 'prime' | 'random';
|
|
21
23
|
/** - Output format for the generated numbers */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/number/types.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IACnC,oCAAoC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAA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AAM,MAAM,aAAa,CAAC,CAAC,SAAS,KAAK,IACxC,CAAC,SAAS,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC"}
|
package/package.json
CHANGED