@8ms/helpers 2.3.29 → 2.3.31
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/crypto/index.d.mts +3 -3
- package/dist/crypto/index.mjs +3 -3
- package/dist/number/index.d.mts +4 -11
- package/dist/number/index.mjs +17 -14
- package/package.json +1 -1
package/dist/crypto/index.d.mts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Decrypt an encoding string using a salt.
|
|
4
4
|
*/
|
|
5
|
-
declare const getDecrypt: (appSalt: string, input: string, salt: string) =>
|
|
5
|
+
declare const getDecrypt: (appSalt: string, input: string, salt: string) => string;
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/crypto/getEncrypt.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* Encrypt an encoding string using a salt.
|
|
10
10
|
*/
|
|
11
|
-
declare const getEncrypt: (appSalt: string, input: string, salt: string) =>
|
|
11
|
+
declare const getEncrypt: (appSalt: string, input: string, salt: string) => string;
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/crypto/getRandom.d.ts
|
|
14
14
|
/**
|
|
@@ -20,6 +20,6 @@ declare const getRandom: (length: number) => string;
|
|
|
20
20
|
/**
|
|
21
21
|
* Encrypt a string using sha256.
|
|
22
22
|
*/
|
|
23
|
-
declare const getSha256: (input: any) =>
|
|
23
|
+
declare const getSha256: (input: any) => string;
|
|
24
24
|
//#endregion
|
|
25
25
|
export { getDecrypt, getEncrypt, getRandom, getSha256 };
|
package/dist/crypto/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { getString } from "../string/index.mjs";
|
|
|
5
5
|
/**
|
|
6
6
|
* Decrypt an encoding string using a salt.
|
|
7
7
|
*/
|
|
8
|
-
const getDecrypt =
|
|
8
|
+
const getDecrypt = (appSalt, input, salt) => {
|
|
9
9
|
const crypto = __require("crypto");
|
|
10
10
|
const ALGORITHM = "aes-256-cbc";
|
|
11
11
|
const customSalt = `${appSalt}-${salt}`;
|
|
@@ -22,7 +22,7 @@ const getDecrypt = async (appSalt, input, salt) => {
|
|
|
22
22
|
/**
|
|
23
23
|
* Encrypt an encoding string using a salt.
|
|
24
24
|
*/
|
|
25
|
-
const getEncrypt =
|
|
25
|
+
const getEncrypt = (appSalt, input, salt) => {
|
|
26
26
|
const crypto = __require("crypto");
|
|
27
27
|
const ALGORITHM = "aes-256-cbc";
|
|
28
28
|
const customSalt = `${appSalt}-${salt}`;
|
|
@@ -47,7 +47,7 @@ const getRandom = (length) => {
|
|
|
47
47
|
/**
|
|
48
48
|
* Encrypt a string using sha256.
|
|
49
49
|
*/
|
|
50
|
-
const getSha256 =
|
|
50
|
+
const getSha256 = (input) => {
|
|
51
51
|
const crypto = __require("crypto");
|
|
52
52
|
const inputString = getString(input);
|
|
53
53
|
return crypto.createHash("sha256").update(inputString).digest("hex");
|
package/dist/number/index.d.mts
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
//#region src/number/
|
|
2
|
-
type FormatProps = {
|
|
3
|
-
compact?: boolean;
|
|
4
|
-
input: any;
|
|
5
|
-
locale?: string;
|
|
6
|
-
minDp?: number;
|
|
7
|
-
maxDp?: number;
|
|
8
|
-
};
|
|
1
|
+
//#region src/number/formatStandard.d.ts
|
|
9
2
|
/**
|
|
10
3
|
* Take a given number and format it.
|
|
11
4
|
*/
|
|
12
|
-
declare const
|
|
5
|
+
declare const formatStandard: (input: any, maxDp?: number, minDp?: number) => string;
|
|
13
6
|
//#endregion
|
|
14
7
|
//#region src/number/formatCurrency.d.ts
|
|
15
8
|
/**
|
|
16
9
|
* Use the International number formatting to return the currency value.
|
|
17
10
|
* https://www.freecodecamp.org/news/how-to-format-number-as-currency-in-javascript-one-line-of-code/
|
|
18
11
|
*/
|
|
19
|
-
declare const formatCurrency: (input: any,
|
|
12
|
+
declare const formatCurrency: (input: any, currency?: string, maxDp?: number, minDp?: number) => string;
|
|
20
13
|
//#endregion
|
|
21
14
|
//#region src/number/getDecimal.d.ts
|
|
22
15
|
/**
|
|
@@ -51,4 +44,4 @@ declare const getNumber: (input: any, defaultValue?: number) => number;
|
|
|
51
44
|
*/
|
|
52
45
|
declare const getPercentIncrease: (current: any, comparison: any, defaultValue: number) => number;
|
|
53
46
|
//#endregion
|
|
54
|
-
export {
|
|
47
|
+
export { formatCurrency, formatStandard, getDecimal, getNumber, getPercent, getPercentIncrease, getSafeDivide };
|
package/dist/number/index.mjs
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { n as getNumber, t as getDecimal } from "../getDecimal-CafxtLhH.mjs";
|
|
2
2
|
|
|
3
|
-
//#region src/number/
|
|
3
|
+
//#region src/number/formatStandard.ts
|
|
4
4
|
/**
|
|
5
5
|
* Take a given number and format it.
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
notation: compact ? "compact" : "standard"
|
|
7
|
+
const formatStandard = (input, maxDp, minDp) => {
|
|
8
|
+
const inputValue = getNumber(input);
|
|
9
|
+
const maximumDp = maxDp ?? 0;
|
|
10
|
+
const minimumDp = minDp ?? maxDp;
|
|
11
|
+
return Intl.NumberFormat(void 0, {
|
|
12
|
+
minimumFractionDigits: maximumDp,
|
|
13
|
+
maximumFractionDigits: minimumDp,
|
|
14
|
+
notation: "standard"
|
|
16
15
|
}).format(inputValue);
|
|
17
16
|
};
|
|
18
17
|
|
|
@@ -22,12 +21,16 @@ const format = (props) => {
|
|
|
22
21
|
* Use the International number formatting to return the currency value.
|
|
23
22
|
* https://www.freecodecamp.org/news/how-to-format-number-as-currency-in-javascript-one-line-of-code/
|
|
24
23
|
*/
|
|
25
|
-
const formatCurrency = (input,
|
|
24
|
+
const formatCurrency = (input, currency = "GBP", maxDp, minDp) => {
|
|
26
25
|
const value = Number(input);
|
|
27
26
|
const currencyClean = currency.toUpperCase().trim();
|
|
28
|
-
|
|
27
|
+
const maximumDp = maxDp ?? 2;
|
|
28
|
+
const minimumDp = minDp ?? maxDp;
|
|
29
|
+
let formatted = new Intl.NumberFormat(void 0, {
|
|
29
30
|
style: "currency",
|
|
30
|
-
currency: currencyClean
|
|
31
|
+
currency: currencyClean,
|
|
32
|
+
minimumFractionDigits: maximumDp,
|
|
33
|
+
maximumFractionDigits: minimumDp
|
|
31
34
|
}).format(value);
|
|
32
35
|
if ("USD" === currencyClean) formatted = formatted.replace("US$", "$");
|
|
33
36
|
return formatted;
|
|
@@ -72,4 +75,4 @@ const getPercentIncrease = (current, comparison, defaultValue) => {
|
|
|
72
75
|
};
|
|
73
76
|
|
|
74
77
|
//#endregion
|
|
75
|
-
export {
|
|
78
|
+
export { formatCurrency, formatStandard, getDecimal, getNumber, getPercent, getPercentIncrease, getSafeDivide };
|