@8ms/helpers 2.3.31 → 2.3.33
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/number/index.d.mts +10 -4
- package/dist/number/index.mjs +22 -6
- package/dist/swr/client/index.d.mts +15 -15
- package/dist/swr/client/index.mjs +1 -1
- package/package.json +1 -1
package/dist/number/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
//#region src/number/
|
|
1
|
+
//#region src/number/formatCompact.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Take a given number and format
|
|
3
|
+
* Take a given number and format as a compact number.
|
|
4
4
|
*/
|
|
5
|
-
declare const
|
|
5
|
+
declare const formatCompact: (input: any, maxDp?: number, minDp?: number) => string;
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/number/formatCurrency.d.ts
|
|
8
8
|
/**
|
|
@@ -11,6 +11,12 @@ declare const formatStandard: (input: any, maxDp?: number, minDp?: number) => st
|
|
|
11
11
|
*/
|
|
12
12
|
declare const formatCurrency: (input: any, currency?: string, maxDp?: number, minDp?: number) => string;
|
|
13
13
|
//#endregion
|
|
14
|
+
//#region src/number/formatStandard.d.ts
|
|
15
|
+
/**
|
|
16
|
+
* Take a given number and format it.
|
|
17
|
+
*/
|
|
18
|
+
declare const formatStandard: (input: any, maxDp?: number, minDp?: number) => string;
|
|
19
|
+
//#endregion
|
|
14
20
|
//#region src/number/getDecimal.d.ts
|
|
15
21
|
/**
|
|
16
22
|
* Return a decimal number after rounding.
|
|
@@ -44,4 +50,4 @@ declare const getNumber: (input: any, defaultValue?: number) => number;
|
|
|
44
50
|
*/
|
|
45
51
|
declare const getPercentIncrease: (current: any, comparison: any, defaultValue: number) => number;
|
|
46
52
|
//#endregion
|
|
47
|
-
export { formatCurrency, formatStandard, getDecimal, getNumber, getPercent, getPercentIncrease, getSafeDivide };
|
|
53
|
+
export { formatCompact, formatCurrency, formatStandard, getDecimal, getNumber, getPercent, getPercentIncrease, getSafeDivide };
|
package/dist/number/index.mjs
CHANGED
|
@@ -1,17 +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/formatCompact.ts
|
|
4
4
|
/**
|
|
5
|
-
* Take a given number and format
|
|
5
|
+
* Take a given number and format as a compact number.
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
7
|
+
const formatCompact = (input, maxDp, minDp) => {
|
|
8
8
|
const inputValue = getNumber(input);
|
|
9
|
-
const maximumDp = maxDp ??
|
|
9
|
+
const maximumDp = maxDp ?? 2;
|
|
10
10
|
const minimumDp = minDp ?? maxDp;
|
|
11
11
|
return Intl.NumberFormat(void 0, {
|
|
12
12
|
minimumFractionDigits: maximumDp,
|
|
13
13
|
maximumFractionDigits: minimumDp,
|
|
14
|
-
notation: "
|
|
14
|
+
notation: "compact"
|
|
15
15
|
}).format(inputValue);
|
|
16
16
|
};
|
|
17
17
|
|
|
@@ -36,6 +36,22 @@ const formatCurrency = (input, currency = "GBP", maxDp, minDp) => {
|
|
|
36
36
|
return formatted;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/number/formatStandard.ts
|
|
41
|
+
/**
|
|
42
|
+
* Take a given number and format it.
|
|
43
|
+
*/
|
|
44
|
+
const formatStandard = (input, maxDp, minDp) => {
|
|
45
|
+
const inputValue = getNumber(input);
|
|
46
|
+
const maximumDp = maxDp ?? 0;
|
|
47
|
+
const minimumDp = minDp ?? maxDp;
|
|
48
|
+
return Intl.NumberFormat(void 0, {
|
|
49
|
+
minimumFractionDigits: maximumDp,
|
|
50
|
+
maximumFractionDigits: minimumDp,
|
|
51
|
+
notation: "standard"
|
|
52
|
+
}).format(inputValue);
|
|
53
|
+
};
|
|
54
|
+
|
|
39
55
|
//#endregion
|
|
40
56
|
//#region src/number/getSafeDivide.ts
|
|
41
57
|
/**
|
|
@@ -75,4 +91,4 @@ const getPercentIncrease = (current, comparison, defaultValue) => {
|
|
|
75
91
|
};
|
|
76
92
|
|
|
77
93
|
//#endregion
|
|
78
|
-
export { formatCurrency, formatStandard, getDecimal, getNumber, getPercent, getPercentIncrease, getSafeDivide };
|
|
94
|
+
export { formatCompact, formatCurrency, formatStandard, getDecimal, getNumber, getPercent, getPercentIncrease, getSafeDivide };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { c as ApiState } from "../../index-DW9yJLtI.mjs";
|
|
2
|
-
|
|
3
1
|
//#region src/swr/client/swr.d.ts
|
|
4
2
|
type Swr = {
|
|
5
3
|
data: any;
|
|
@@ -7,40 +5,42 @@ type Swr = {
|
|
|
7
5
|
skipFetch?: boolean;
|
|
8
6
|
url: string;
|
|
9
7
|
};
|
|
10
|
-
type SwrResponse = {
|
|
11
|
-
data
|
|
12
|
-
error: any;
|
|
8
|
+
type SwrResponse<TData = unknown> = {
|
|
9
|
+
data?: TData;
|
|
13
10
|
fetcher: Function;
|
|
11
|
+
error?: unknown;
|
|
14
12
|
mutate: {
|
|
15
|
-
data:
|
|
13
|
+
data: object;
|
|
16
14
|
url: string;
|
|
17
15
|
};
|
|
18
|
-
state?:
|
|
19
|
-
swrMutate:
|
|
16
|
+
state?: unknown;
|
|
17
|
+
swrMutate: unknown;
|
|
20
18
|
};
|
|
21
19
|
/**
|
|
22
|
-
* Check to see if a single SWR has
|
|
20
|
+
* Check to see if a single SWR has data and no error.
|
|
23
21
|
*/
|
|
24
|
-
declare const isData: (swr: SwrResponse) =>
|
|
22
|
+
declare const isData: <TData>(swr: SwrResponse<TData>) => swr is SwrResponse<TData> & {
|
|
23
|
+
data: TData;
|
|
24
|
+
};
|
|
25
25
|
/**
|
|
26
26
|
* Check to see if a single SWR is loading.
|
|
27
27
|
*/
|
|
28
|
-
declare const isLoading: (swr: SwrResponse) => boolean;
|
|
28
|
+
declare const isLoading: <TData>(swr: SwrResponse<TData>) => boolean;
|
|
29
29
|
/**
|
|
30
30
|
* Check to see if a single SWR has an error.
|
|
31
31
|
*/
|
|
32
|
-
declare const isError: (swr: SwrResponse) => boolean;
|
|
32
|
+
declare const isError: <TData>(swr: SwrResponse<TData>) => boolean;
|
|
33
33
|
/**
|
|
34
34
|
* Are any of SWRs loading
|
|
35
35
|
*/
|
|
36
|
-
declare const isAnyLoading: (swrs: SwrResponse[]) => boolean;
|
|
36
|
+
declare const isAnyLoading: <TData>(swrs: SwrResponse<TData>[]) => boolean;
|
|
37
37
|
/**
|
|
38
38
|
* Are any of the SWRs marked as an error.
|
|
39
39
|
*/
|
|
40
|
-
declare const isAnyError: (swrs: SwrResponse[]) => boolean;
|
|
40
|
+
declare const isAnyError: <TData>(swrs: SwrResponse<TData>[]) => boolean;
|
|
41
41
|
/**
|
|
42
42
|
* Are all SWRs data ready.
|
|
43
43
|
*/
|
|
44
|
-
declare const isAllData: (swrs: SwrResponse[]) => boolean;
|
|
44
|
+
declare const isAllData: <TData>(swrs: SwrResponse<TData>[]) => boolean;
|
|
45
45
|
//#endregion
|
|
46
46
|
export { Swr, SwrResponse, isAllData, isAnyError, isAnyLoading, isData, isError, isLoading };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/swr/client/swr.ts
|
|
2
2
|
/**
|
|
3
|
-
* Check to see if a single SWR has
|
|
3
|
+
* Check to see if a single SWR has data and no error.
|
|
4
4
|
*/
|
|
5
5
|
const isData = (swr) => (void 0 === swr.error || null === swr.error) && "undefined" !== typeof swr.data && "undefined" !== swr.data;
|
|
6
6
|
/**
|