@jhqn/utils-msw 0.6.0 → 1.1.0
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/index.d.ts +0 -4
- package/dist/index.js +1 -2
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { PageRes, Res } from "@jhqn/utils-core";
|
|
2
2
|
import { HttpResponse, http } from "msw";
|
|
3
|
-
//#region types/index.d.ts
|
|
4
3
|
type MaybeFn<T> = T | (() => T);
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/msw.d.ts
|
|
7
4
|
export declare const commonRes: <T>(fn: MaybeFn<T>) => Promise<HttpResponse<Res<T>>>;
|
|
8
5
|
export declare const commonArrRes: <T>(fn: MaybeFn<T>, range: [min: number, max: number] | number) => Promise<HttpResponse<Res<T[]>>>;
|
|
9
6
|
export declare const commonPageRes: <T>(fn: MaybeFn<T>, resolver: Parameters<Parameters<typeof http.get>[1]>[0], total?: number) => Promise<HttpResponse<PageRes<T>>>;
|
|
10
|
-
//#endregion
|
|
11
7
|
export type { MaybeFn };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getMockData, getMockDataList, isNumber } from "@jhqn/utils-core";
|
|
|
2
2
|
import { fakeIntRange } from "@jhqn/utils-faker";
|
|
3
3
|
import { HttpResponse } from "msw";
|
|
4
4
|
import { delay } from "msw/utils/delay";
|
|
5
|
-
|
|
5
|
+
// src/msw.ts
|
|
6
6
|
const randomDelay = () => delay(fakeIntRange(100, 1e3));
|
|
7
7
|
const fnRes = (fn) => fn instanceof Function ? fn() : fn;
|
|
8
8
|
const commonRes = async (fn) => {
|
|
@@ -29,5 +29,4 @@ const commonPageRes = async (fn, resolver, total = 42) => {
|
|
|
29
29
|
searchCount: false
|
|
30
30
|
}));
|
|
31
31
|
};
|
|
32
|
-
//#endregion
|
|
33
32
|
export { commonArrRes, commonPageRes, commonRes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jhqn/utils-msw",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"jade",
|
|
6
6
|
"utils"
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@jhqn/utils-core": "
|
|
37
|
-
"@jhqn/utils-faker": "
|
|
36
|
+
"@jhqn/utils-core": "1.1.0",
|
|
37
|
+
"@jhqn/utils-faker": "1.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"msw": "^3.0.
|
|
40
|
+
"msw": "^3.0.3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"msw": "^3.0.0"
|