@8ms/helpers 2.3.31 → 2.3.32

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.
@@ -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: any;
12
- error: any;
8
+ type SwrResponse<TData = unknown> = {
9
+ data?: TData;
13
10
  fetcher: Function;
11
+ error?: unknown;
14
12
  mutate: {
15
- data: any;
13
+ data: object;
16
14
  url: string;
17
15
  };
18
- state?: ApiState;
19
- swrMutate: Function;
16
+ state?: unknown;
17
+ swrMutate: unknown;
20
18
  };
21
19
  /**
22
- * Check to see if a single SWR has an error.
20
+ * Check to see if a single SWR has data and no error.
23
21
  */
24
- declare const isData: (swr: SwrResponse) => boolean;
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 an error.
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
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.3.31",
4
+ "version": "2.3.32",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"