@bemedev/dev-utils 1.1.1 → 1.3.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/README.md +121 -0
- package/lib/_virtual/_rolldown/runtime.cjs +1 -1
- package/lib/build-tests/addTarball.cjs +5 -1
- package/lib/build-tests/addTarball.cjs.map +1 -1
- package/lib/build-tests/addTarball.d.ts +3 -0
- package/lib/build-tests/addTarball.js +5 -1
- package/lib/build-tests/addTarball.js.map +1 -1
- package/lib/build-tests/buildPackageJson.cjs +17 -9
- package/lib/build-tests/buildPackageJson.cjs.map +1 -1
- package/lib/build-tests/buildPackageJson.d.ts +5 -0
- package/lib/build-tests/buildPackageJson.js +17 -9
- package/lib/build-tests/buildPackageJson.js.map +1 -1
- package/lib/build-tests/cleanup.cjs +3 -0
- package/lib/build-tests/cleanup.cjs.map +1 -1
- package/lib/build-tests/cleanup.d.ts +3 -0
- package/lib/build-tests/cleanup.js +3 -0
- package/lib/build-tests/cleanup.js.map +1 -1
- package/lib/build-tests/cli/cli.cjs +6 -0
- package/lib/build-tests/cli/cli.cjs.map +1 -1
- package/lib/build-tests/cli/cli.d.ts +6 -0
- package/lib/build-tests/cli/cli.js +6 -0
- package/lib/build-tests/cli/cli.js.map +1 -1
- package/lib/build-tests/cli/index.cjs.map +1 -1
- package/lib/build-tests/cli/post.cjs +3 -0
- package/lib/build-tests/cli/post.cjs.map +1 -1
- package/lib/build-tests/cli/post.d.ts +3 -0
- package/lib/build-tests/cli/post.js +3 -0
- package/lib/build-tests/cli/post.js.map +1 -1
- package/lib/build-tests/cli/pre.cjs +3 -0
- package/lib/build-tests/cli/pre.cjs.map +1 -1
- package/lib/build-tests/cli/pre.d.ts +3 -0
- package/lib/build-tests/cli/pre.js +3 -0
- package/lib/build-tests/cli/pre.js.map +1 -1
- package/lib/build-tests/cli/test.cjs +3 -0
- package/lib/build-tests/cli/test.cjs.map +1 -1
- package/lib/build-tests/cli/test.d.ts +3 -0
- package/lib/build-tests/cli/test.js +3 -0
- package/lib/build-tests/cli/test.js.map +1 -1
- package/lib/build-tests/constants.cjs +42 -0
- package/lib/build-tests/constants.cjs.map +1 -1
- package/lib/build-tests/constants.d.ts +42 -0
- package/lib/build-tests/constants.js +42 -0
- package/lib/build-tests/constants.js.map +1 -1
- package/lib/build-tests/getRelativePath.cjs +7 -0
- package/lib/build-tests/getRelativePath.cjs.map +1 -1
- package/lib/build-tests/getRelativePath.d.ts +7 -0
- package/lib/build-tests/getRelativePath.js +7 -0
- package/lib/build-tests/getRelativePath.js.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.cjs +5 -0
- package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.d.ts +5 -0
- package/lib/build-tests/getTypescriptOutdir.js +5 -0
- package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
- package/lib/build-tests/import.cjs +9 -0
- package/lib/build-tests/import.cjs.map +1 -1
- package/lib/build-tests/import.d.ts +9 -0
- package/lib/build-tests/import.js +9 -0
- package/lib/build-tests/import.js.map +1 -1
- package/lib/build-tests/imports/create.cjs +7 -0
- package/lib/build-tests/imports/create.cjs.map +1 -1
- package/lib/build-tests/imports/create.d.ts +13 -0
- package/lib/build-tests/imports/create.js +7 -0
- package/lib/build-tests/imports/create.js.map +1 -1
- package/lib/build-tests/imports/helper.cjs +9 -0
- package/lib/build-tests/imports/helper.cjs.map +1 -1
- package/lib/build-tests/imports/helper.d.ts +12 -0
- package/lib/build-tests/imports/helper.js +9 -0
- package/lib/build-tests/imports/helper.js.map +1 -1
- package/lib/build-tests/pack.cjs +7 -1
- package/lib/build-tests/pack.cjs.map +1 -1
- package/lib/build-tests/pack.d.ts +5 -0
- package/lib/build-tests/pack.js +7 -1
- package/lib/build-tests/pack.js.map +1 -1
- package/lib/plugins/hmr.cjs +72 -0
- package/lib/plugins/hmr.cjs.map +1 -0
- package/lib/plugins/hmr.d.ts +22 -0
- package/lib/plugins/hmr.js +71 -0
- package/lib/plugins/hmr.js.map +1 -0
- package/lib/plugins/index.cjs +5 -0
- package/lib/plugins/index.d.ts +2 -0
- package/lib/plugins/index.js +3 -0
- package/lib/plugins/suppressWarnings.cjs +37 -0
- package/lib/plugins/suppressWarnings.cjs.map +1 -0
- package/lib/plugins/suppressWarnings.d.ts +12 -0
- package/lib/plugins/suppressWarnings.js +36 -0
- package/lib/plugins/suppressWarnings.js.map +1 -0
- package/lib/rolldown-config/config.cjs +13 -5
- package/lib/rolldown-config/config.cjs.map +1 -1
- package/lib/rolldown-config/config.d.ts +7 -0
- package/lib/rolldown-config/config.js +13 -5
- package/lib/rolldown-config/config.js.map +1 -1
- package/lib/rolldown-config/constants.cjs +15 -0
- package/lib/rolldown-config/constants.cjs.map +1 -1
- package/lib/rolldown-config/constants.d.ts +15 -0
- package/lib/rolldown-config/constants.js +15 -0
- package/lib/rolldown-config/constants.js.map +1 -1
- package/lib/rolldown-config/helpers.cjs +16 -1
- package/lib/rolldown-config/helpers.cjs.map +1 -1
- package/lib/rolldown-config/helpers.d.ts +14 -0
- package/lib/rolldown-config/helpers.js +16 -1
- package/lib/rolldown-config/helpers.js.map +1 -1
- package/lib/rolldown-config/input.cjs +8 -0
- package/lib/rolldown-config/input.cjs.map +1 -1
- package/lib/rolldown-config/input.d.ts +8 -0
- package/lib/rolldown-config/input.js +8 -0
- package/lib/rolldown-config/input.js.map +1 -1
- package/lib/rolldown-config/output.cjs +8 -0
- package/lib/rolldown-config/output.cjs.map +1 -1
- package/lib/rolldown-config/output.d.ts +8 -0
- package/lib/rolldown-config/output.js +8 -0
- package/lib/rolldown-config/output.js.map +1 -1
- package/lib/rolldown-config/plugins/circulars.cjs +5 -5
- package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
- package/lib/rolldown-config/plugins/circulars.d.ts +10 -6
- package/lib/rolldown-config/plugins/circulars.js +5 -5
- package/lib/rolldown-config/plugins/circulars.js.map +1 -1
- package/lib/rolldown-config/plugins/clean.cjs +10 -1
- package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
- package/lib/rolldown-config/plugins/clean.d.ts +10 -0
- package/lib/rolldown-config/plugins/clean.js +10 -1
- package/lib/rolldown-config/plugins/clean.js.map +1 -1
- package/lib/rolldown-config/plugins/externals.cjs +4 -3
- package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
- package/lib/rolldown-config/plugins/externals.d.ts +7 -3
- package/lib/rolldown-config/plugins/externals.js +4 -3
- package/lib/rolldown-config/plugins/externals.js.map +1 -1
- package/lib/rolldown-config/plugins/index.cjs +6 -0
- package/lib/rolldown-config/plugins/index.cjs.map +1 -1
- package/lib/rolldown-config/plugins/index.d.ts +6 -0
- package/lib/rolldown-config/plugins/index.js +6 -0
- package/lib/rolldown-config/plugins/index.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.cjs +7 -0
- package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.cjs +15 -0
- package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.d.ts +15 -0
- package/lib/rolldown-config/plugins/typescript.config.js +15 -0
- package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.d.ts +10 -0
- package/lib/rolldown-config/plugins/typescript.fast.cjs +9 -1
- package/lib/rolldown-config/plugins/typescript.fast.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.fast.d.ts +10 -0
- package/lib/rolldown-config/plugins/typescript.fast.js +9 -1
- package/lib/rolldown-config/plugins/typescript.fast.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.js +7 -0
- package/lib/rolldown-config/plugins/typescript.js.map +1 -1
- package/lib/rolldown-config/types.d.ts +18 -0
- package/lib/utils/array.cjs +7 -0
- package/lib/utils/array.cjs.map +1 -1
- package/lib/utils/array.d.ts +8 -0
- package/lib/utils/array.js +7 -0
- package/lib/utils/array.js.map +1 -1
- package/lib/utils/bemedev/globals/types.d.ts +20 -0
- package/lib/utils/bemedev/globals/utils/expandFn.cjs +11 -0
- package/lib/utils/bemedev/globals/utils/expandFn.cjs.map +1 -1
- package/lib/utils/bemedev/globals/utils/expandFn.d.ts +11 -0
- package/lib/utils/bemedev/globals/utils/expandFn.js +11 -0
- package/lib/utils/bemedev/globals/utils/expandFn.js.map +1 -1
- package/lib/utils/clamp.cjs +18 -0
- package/lib/utils/clamp.cjs.map +1 -0
- package/lib/utils/clamp.d.ts +10 -0
- package/lib/utils/clamp.js +17 -0
- package/lib/utils/clamp.js.map +1 -0
- package/lib/utils/identity.cjs +9 -0
- package/lib/utils/identity.cjs.map +1 -1
- package/lib/utils/identity.d.ts +9 -0
- package/lib/utils/identity.js +9 -0
- package/lib/utils/identity.js.map +1 -1
- package/lib/utils/index.cjs +2 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +2 -1
- package/lib/utils/sleep.cjs +7 -0
- package/lib/utils/sleep.cjs.map +1 -1
- package/lib/utils/sleep.d.ts +7 -0
- package/lib/utils/sleep.js +7 -0
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/types.d.ts +17 -1
- package/lib/vitest-exclude/constants.cjs +3 -0
- package/lib/vitest-exclude/constants.cjs.map +1 -1
- package/lib/vitest-exclude/constants.d.ts +3 -0
- package/lib/vitest-exclude/constants.js +3 -0
- package/lib/vitest-exclude/constants.js.map +1 -1
- package/lib/vitest-exclude/types.d.ts +11 -0
- package/lib/vitest-exclude/vitest.cjs +25 -12
- package/lib/vitest-exclude/vitest.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.d.ts +9 -8
- package/lib/vitest-exclude/vitest.js +25 -12
- package/lib/vitest-exclude/vitest.js.map +1 -1
- package/lib/vitest-exclude/vitest.utils.cjs +30 -0
- package/lib/vitest-exclude/vitest.utils.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.utils.d.ts +30 -0
- package/lib/vitest-exclude/vitest.utils.js +30 -0
- package/lib/vitest-exclude/vitest.utils.js.map +1 -1
- package/lib/vitest-extended/acceptation.cjs +11 -2
- package/lib/vitest-extended/acceptation.cjs.map +1 -1
- package/lib/vitest-extended/acceptation.d.ts +9 -1
- package/lib/vitest-extended/acceptation.js +11 -2
- package/lib/vitest-extended/acceptation.js.map +1 -1
- package/lib/vitest-extended/createTests.cjs +34 -27
- package/lib/vitest-extended/createTests.cjs.map +1 -1
- package/lib/vitest-extended/createTests.d.ts +20 -37
- package/lib/vitest-extended/createTests.js +34 -27
- package/lib/vitest-extended/createTests.js.map +1 -1
- package/lib/vitest-extended/createTests.types.d.ts +13 -2
- package/lib/vitest-extended/done.cjs +18 -15
- package/lib/vitest-extended/done.cjs.map +1 -1
- package/lib/vitest-extended/done.d.ts +6 -5
- package/lib/vitest-extended/done.js +18 -15
- package/lib/vitest-extended/done.js.map +1 -1
- package/lib/vitest-extended/each/error.cjs +12 -0
- package/lib/vitest-extended/each/error.cjs.map +1 -1
- package/lib/vitest-extended/each/error.d.ts +12 -0
- package/lib/vitest-extended/each/error.js +12 -0
- package/lib/vitest-extended/each/error.js.map +1 -1
- package/lib/vitest-extended/each/error.types.d.ts +17 -0
- package/lib/vitest-extended/each/pass.cjs +9 -20
- package/lib/vitest-extended/each/pass.cjs.map +1 -1
- package/lib/vitest-extended/each/pass.d.ts +9 -20
- package/lib/vitest-extended/each/pass.js +9 -20
- package/lib/vitest-extended/each/pass.js.map +1 -1
- package/lib/vitest-extended/each/pass.types.d.ts +24 -0
- package/lib/vitest-extended/fakeWaiter.cjs +7 -0
- package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
- package/lib/vitest-extended/fakeWaiter.d.ts +32 -0
- package/lib/vitest-extended/fakeWaiter.js +7 -0
- package/lib/vitest-extended/fakeWaiter.js.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.cjs +11 -0
- package/lib/vitest-extended/fixtures/coverage.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.js +11 -0
- package/lib/vitest-extended/fixtures/coverage.js.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.cjs +9 -4
- package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.js +9 -4
- package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.cjs +18 -0
- package/lib/vitest-extended/fixtures/toUpper.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.js +18 -0
- package/lib/vitest-extended/fixtures/toUpper.js.map +1 -1
- package/lib/vitest-extended/fixtures/vitest.cjs +3 -0
- package/lib/vitest-extended/fixtures/vitest.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/vitest.js +3 -0
- package/lib/vitest-extended/fixtures/vitest.js.map +1 -1
- package/lib/vitest-extended/fixtures/zod.cjs +22 -0
- package/lib/vitest-extended/fixtures/zod.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/zod.js +22 -0
- package/lib/vitest-extended/fixtures/zod.js.map +1 -1
- package/lib/vitest-extended/identity.cjs +18 -0
- package/lib/vitest-extended/identity.cjs.map +1 -1
- package/lib/vitest-extended/identity.d.ts +18 -0
- package/lib/vitest-extended/identity.js +18 -0
- package/lib/vitest-extended/identity.js.map +1 -1
- package/lib/vitest-extended/isDefined.cjs +9 -0
- package/lib/vitest-extended/isDefined.cjs.map +1 -1
- package/lib/vitest-extended/isDefined.d.ts +9 -0
- package/lib/vitest-extended/isDefined.js +9 -0
- package/lib/vitest-extended/isDefined.js.map +1 -1
- package/lib/vitest-extended/isFunction.cjs +7 -0
- package/lib/vitest-extended/isFunction.cjs.map +1 -1
- package/lib/vitest-extended/isFunction.d.ts +7 -0
- package/lib/vitest-extended/isFunction.js +7 -0
- package/lib/vitest-extended/isFunction.js.map +1 -1
- package/lib/vitest-extended/project.cjs +7 -0
- package/lib/vitest-extended/project.cjs.map +1 -1
- package/lib/vitest-extended/project.d.ts +7 -0
- package/lib/vitest-extended/project.js +7 -0
- package/lib/vitest-extended/project.js.map +1 -1
- package/lib/vitest-extended/toArray.cjs +6 -0
- package/lib/vitest-extended/toArray.cjs.map +1 -1
- package/lib/vitest-extended/toArray.d.ts +6 -0
- package/lib/vitest-extended/toArray.js +6 -0
- package/lib/vitest-extended/toArray.js.map +1 -1
- package/lib/vitest-extended/toStringFlat.cjs +8 -0
- package/lib/vitest-extended/toStringFlat.cjs.map +1 -1
- package/lib/vitest-extended/toStringFlat.d.ts +8 -0
- package/lib/vitest-extended/toStringFlat.js +8 -0
- package/lib/vitest-extended/toStringFlat.js.map +1 -1
- package/lib/vitest-extended/types.d.ts +64 -0
- package/package.json +14 -9
|
@@ -9,26 +9,12 @@ const useEachCases = (func, transform = require_vitest_extended_identity.identit
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Runs parameterized tests with strict equality checks across multiple cases.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* @param func - Function to test.
|
|
15
|
+
* @param transform - Optional transformer applied to the return value.
|
|
15
16
|
*
|
|
16
|
-
* @
|
|
17
|
-
* @type R ReturnType of the function
|
|
18
|
-
* @param func The function to test
|
|
19
|
-
* @param cases The cases to test, The invite is the first arguments. It's
|
|
20
|
-
* an array of Array.
|
|
21
|
-
*
|
|
22
|
-
* - #1 The first arg is the invite of the test
|
|
23
|
-
* - #2 The second arg is the parameters to to pass to the function. It's
|
|
24
|
-
* an array (param array).
|
|
25
|
-
* - #3 The third arg is the expected result
|
|
26
|
-
*
|
|
27
|
-
* Example: For a function like **_(arg1: string)=>any**_, the second arg
|
|
28
|
-
* with be : **_[string]**_
|
|
29
|
-
* @if R are not provided, the return is a function to test with TestArgs arguments
|
|
30
|
-
*
|
|
31
|
-
* @else It tests every cases provided
|
|
17
|
+
* @returns Function accepting test cases to execute.
|
|
32
18
|
*/
|
|
33
19
|
const useEach = (func, transform) => {
|
|
34
20
|
return (...cases) => useEachCases(func, transform, ...cases);
|
|
@@ -39,9 +25,12 @@ const useEachAsyncCases = (f, transform = require_vitest_extended_identity.ident
|
|
|
39
25
|
});
|
|
40
26
|
};
|
|
41
27
|
/**
|
|
42
|
-
*
|
|
28
|
+
* Runs asynchronous parameterized tests with strict equality checks across multiple cases.
|
|
29
|
+
*
|
|
30
|
+
* @param func - Async function to test.
|
|
31
|
+
* @param transform - Optional transformer applied to the resolved return value.
|
|
43
32
|
*
|
|
44
|
-
*
|
|
33
|
+
* @returns Function accepting test cases to execute.
|
|
45
34
|
*/
|
|
46
35
|
const useEachAsync = (func, transform) => {
|
|
47
36
|
return (...cases) => useEachAsyncCases(func, transform, ...cases);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pass.cjs","names":["identity","toArrayVitest","defaultEquality"],"sources":["../../../src/vitest-extended/each/pass.ts"],"sourcesContent":["import { test } from 'vitest';\n\nimport { defaultEquality, identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type {\n _UseAsyncEach_F,\n _UseEach_F,\n UseAsyncEach_F,\n UseEach_F,\n} from './pass.types';\n\n// #region Sync\nconst useEachCases: _UseEach_F = (\n func,\n transform = identity as any,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest(cases))(\n '%s',\n (_, args, expected, test = defaultEquality) => {\n const value = transform(func(...args));\n return test(value, expected);\n },\n );\n};\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"pass.cjs","names":["identity","toArrayVitest","defaultEquality"],"sources":["../../../src/vitest-extended/each/pass.ts"],"sourcesContent":["import { test } from 'vitest';\n\nimport { defaultEquality, identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type {\n _UseAsyncEach_F,\n _UseEach_F,\n UseAsyncEach_F,\n UseEach_F,\n} from './pass.types';\n\n// #region Sync\nconst useEachCases: _UseEach_F = (\n func,\n transform = identity as any,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest(cases))(\n '%s',\n (_, args, expected, test = defaultEquality) => {\n const value = transform(func(...args));\n return test(value, expected);\n },\n );\n};\n\n/**\n * Runs parameterized tests with strict equality checks across multiple cases.\n *\n * @param func - Function to test.\n * @param transform - Optional transformer applied to the return value.\n *\n * @returns Function accepting test cases to execute.\n */\nexport const useEach: UseEach_F = (func, transform) => {\n return (...cases) => useEachCases(func, transform, ...cases);\n};\n// #endregion\n\n// #region Async\nconst useEachAsyncCases: _UseAsyncEach_F = (\n f,\n transform = identity as any,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest(cases))(\n '%s',\n async (_, args, expected, test = defaultEquality) => {\n const _value = await f(...args);\n const value = await transform(_value);\n return test(value, expected);\n },\n );\n};\n\n/**\n * Runs asynchronous parameterized tests with strict equality checks across multiple cases.\n *\n * @param func - Async function to test.\n * @param transform - Optional transformer applied to the resolved return value.\n *\n * @returns Function accepting test cases to execute.\n */\nexport const useEachAsync: UseAsyncEach_F = (func, transform) => {\n return (...cases) => useEachAsyncCases(func, transform, ...cases);\n};\n\n// #endregion\n"],"mappings":";;;;;AAYA,MAAM,gBACJ,MACA,YAAYA,iCAAAA,UACZ,GAAG,UACA;CACH,OAAA,KAAK,WAAW,KAAKC,gCAAAA,cAAc,KAAK,CAAC,CAAC,CACxC,OACC,GAAG,MAAM,UAAU,OAAOC,iCAAAA,oBAAoB;EAE7C,OAAO,KADO,UAAU,KAAK,GAAG,IAAI,CACpB,GAAG,QAAQ;CAC7B,CACF;AACF;;;;;;;;;AAUA,MAAa,WAAsB,MAAM,cAAc;CACrD,QAAQ,GAAG,UAAU,aAAa,MAAM,WAAW,GAAG,KAAK;AAC7D;AAIA,MAAM,qBACJ,GACA,YAAYF,iCAAAA,UACZ,GAAG,UACA;CACH,OAAA,KAAK,WAAW,KAAKC,gCAAAA,cAAc,KAAK,CAAC,CAAC,CACxC,MACA,OAAO,GAAG,MAAM,UAAU,OAAOC,iCAAAA,oBAAoB;EAGnD,OAAO,KAAK,MADQ,UAAU,MADT,EAAE,GAAG,IAAI,CACM,GACjB,QAAQ;CAC7B,CACF;AACF;;;;;;;;;AAUA,MAAa,gBAAgC,MAAM,cAAc;CAC/D,QAAQ,GAAG,UAAU,kBAAkB,MAAM,WAAW,GAAG,KAAK;AAClE"}
|
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
import type { UseAsyncEach_F, UseEach_F } from './pass.types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Runs parameterized tests with strict equality checks across multiple cases.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* @param func - Function to test.
|
|
6
|
+
* @param transform - Optional transformer applied to the return value.
|
|
6
7
|
*
|
|
7
|
-
* @
|
|
8
|
-
* @type R ReturnType of the function
|
|
9
|
-
* @param func The function to test
|
|
10
|
-
* @param cases The cases to test, The invite is the first arguments. It's
|
|
11
|
-
* an array of Array.
|
|
12
|
-
*
|
|
13
|
-
* - #1 The first arg is the invite of the test
|
|
14
|
-
* - #2 The second arg is the parameters to to pass to the function. It's
|
|
15
|
-
* an array (param array).
|
|
16
|
-
* - #3 The third arg is the expected result
|
|
17
|
-
*
|
|
18
|
-
* Example: For a function like **_(arg1: string)=>any**_, the second arg
|
|
19
|
-
* with be : **_[string]**_
|
|
20
|
-
* @if R are not provided, the return is a function to test with TestArgs arguments
|
|
21
|
-
*
|
|
22
|
-
* @else It tests every cases provided
|
|
8
|
+
* @returns Function accepting test cases to execute.
|
|
23
9
|
*/
|
|
24
10
|
export declare const useEach: UseEach_F;
|
|
25
11
|
/**
|
|
26
|
-
*
|
|
12
|
+
* Runs asynchronous parameterized tests with strict equality checks across multiple cases.
|
|
13
|
+
*
|
|
14
|
+
* @param func - Async function to test.
|
|
15
|
+
* @param transform - Optional transformer applied to the resolved return value.
|
|
27
16
|
*
|
|
28
|
-
*
|
|
17
|
+
* @returns Function accepting test cases to execute.
|
|
29
18
|
*/
|
|
30
19
|
export declare const useEachAsync: UseAsyncEach_F;
|
|
@@ -8,26 +8,12 @@ const useEachCases = (func, transform = identity, ...cases) => {
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Runs parameterized tests with strict equality checks across multiple cases.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* @param func - Function to test.
|
|
14
|
+
* @param transform - Optional transformer applied to the return value.
|
|
14
15
|
*
|
|
15
|
-
* @
|
|
16
|
-
* @type R ReturnType of the function
|
|
17
|
-
* @param func The function to test
|
|
18
|
-
* @param cases The cases to test, The invite is the first arguments. It's
|
|
19
|
-
* an array of Array.
|
|
20
|
-
*
|
|
21
|
-
* - #1 The first arg is the invite of the test
|
|
22
|
-
* - #2 The second arg is the parameters to to pass to the function. It's
|
|
23
|
-
* an array (param array).
|
|
24
|
-
* - #3 The third arg is the expected result
|
|
25
|
-
*
|
|
26
|
-
* Example: For a function like **_(arg1: string)=>any**_, the second arg
|
|
27
|
-
* with be : **_[string]**_
|
|
28
|
-
* @if R are not provided, the return is a function to test with TestArgs arguments
|
|
29
|
-
*
|
|
30
|
-
* @else It tests every cases provided
|
|
16
|
+
* @returns Function accepting test cases to execute.
|
|
31
17
|
*/
|
|
32
18
|
const useEach = (func, transform) => {
|
|
33
19
|
return (...cases) => useEachCases(func, transform, ...cases);
|
|
@@ -38,9 +24,12 @@ const useEachAsyncCases = (f, transform = identity, ...cases) => {
|
|
|
38
24
|
});
|
|
39
25
|
};
|
|
40
26
|
/**
|
|
41
|
-
*
|
|
27
|
+
* Runs asynchronous parameterized tests with strict equality checks across multiple cases.
|
|
28
|
+
*
|
|
29
|
+
* @param func - Async function to test.
|
|
30
|
+
* @param transform - Optional transformer applied to the resolved return value.
|
|
42
31
|
*
|
|
43
|
-
*
|
|
32
|
+
* @returns Function accepting test cases to execute.
|
|
44
33
|
*/
|
|
45
34
|
const useEachAsync = (func, transform) => {
|
|
46
35
|
return (...cases) => useEachAsyncCases(func, transform, ...cases);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pass.js","names":[],"sources":["../../../src/vitest-extended/each/pass.ts"],"sourcesContent":["import { test } from 'vitest';\n\nimport { defaultEquality, identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type {\n _UseAsyncEach_F,\n _UseEach_F,\n UseAsyncEach_F,\n UseEach_F,\n} from './pass.types';\n\n// #region Sync\nconst useEachCases: _UseEach_F = (\n func,\n transform = identity as any,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest(cases))(\n '%s',\n (_, args, expected, test = defaultEquality) => {\n const value = transform(func(...args));\n return test(value, expected);\n },\n );\n};\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"pass.js","names":[],"sources":["../../../src/vitest-extended/each/pass.ts"],"sourcesContent":["import { test } from 'vitest';\n\nimport { defaultEquality, identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type {\n _UseAsyncEach_F,\n _UseEach_F,\n UseAsyncEach_F,\n UseEach_F,\n} from './pass.types';\n\n// #region Sync\nconst useEachCases: _UseEach_F = (\n func,\n transform = identity as any,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest(cases))(\n '%s',\n (_, args, expected, test = defaultEquality) => {\n const value = transform(func(...args));\n return test(value, expected);\n },\n );\n};\n\n/**\n * Runs parameterized tests with strict equality checks across multiple cases.\n *\n * @param func - Function to test.\n * @param transform - Optional transformer applied to the return value.\n *\n * @returns Function accepting test cases to execute.\n */\nexport const useEach: UseEach_F = (func, transform) => {\n return (...cases) => useEachCases(func, transform, ...cases);\n};\n// #endregion\n\n// #region Async\nconst useEachAsyncCases: _UseAsyncEach_F = (\n f,\n transform = identity as any,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest(cases))(\n '%s',\n async (_, args, expected, test = defaultEquality) => {\n const _value = await f(...args);\n const value = await transform(_value);\n return test(value, expected);\n },\n );\n};\n\n/**\n * Runs asynchronous parameterized tests with strict equality checks across multiple cases.\n *\n * @param func - Async function to test.\n * @param transform - Optional transformer applied to the resolved return value.\n *\n * @returns Function accepting test cases to execute.\n */\nexport const useEachAsync: UseAsyncEach_F = (func, transform) => {\n return (...cases) => useEachAsyncCases(func, transform, ...cases);\n};\n\n// #endregion\n"],"mappings":";;;;AAYA,MAAM,gBACJ,MACA,YAAY,UACZ,GAAG,UACA;CACH,KAAK,WAAW,KAAK,cAAc,KAAK,CAAC,CAAC,CACxC,OACC,GAAG,MAAM,UAAU,OAAO,oBAAoB;EAE7C,OAAO,KADO,UAAU,KAAK,GAAG,IAAI,CACpB,GAAG,QAAQ;CAC7B,CACF;AACF;;;;;;;;;AAUA,MAAa,WAAsB,MAAM,cAAc;CACrD,QAAQ,GAAG,UAAU,aAAa,MAAM,WAAW,GAAG,KAAK;AAC7D;AAIA,MAAM,qBACJ,GACA,YAAY,UACZ,GAAG,UACA;CACH,KAAK,WAAW,KAAK,cAAc,KAAK,CAAC,CAAC,CACxC,MACA,OAAO,GAAG,MAAM,UAAU,OAAO,oBAAoB;EAGnD,OAAO,KAAK,MADQ,UAAU,MADT,EAAE,GAAG,IAAI,CACM,GACjB,QAAQ;CAC7B,CACF;AACF;;;;;;;;;AAUA,MAAa,gBAAgC,MAAM,cAAc;CAC/D,QAAQ,GAAG,UAAU,kBAAkB,MAAM,WAAW,GAAG,KAAK;AAClE"}
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import type { Fn } from '../../utils/bemedev/globals/types';
|
|
2
2
|
import type { ChainedFn, Identity, NextFn, TestArgs } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Runner function signature for synchronous parameterized tests.
|
|
5
|
+
*
|
|
6
|
+
* @template | {@linkcode Fn} `F` - Source function under test.
|
|
7
|
+
* @template | {@linkcode NextFn} `T` - Output transformer type, defaults to {@linkcode Identity}.
|
|
8
|
+
*/
|
|
3
9
|
export type _UseEach_F = <F extends Fn, T extends NextFn<F> = Identity<F>>(f: F, transform?: T, ...cases: TestArgs<ChainedFn<F, T>>) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Higher-order function returning a test runner for synchronous parameterized tests.
|
|
12
|
+
*
|
|
13
|
+
* @template | {@linkcode Fn} `F` - Source function under test.
|
|
14
|
+
* @template | {@linkcode NextFn} `T` - Output transformer type, defaults to {@linkcode Identity}.
|
|
15
|
+
*/
|
|
4
16
|
export type UseEach_F = <F extends Fn, T extends NextFn<F> = Identity<F>>(f: F, transform?: T) => (...cases: TestArgs<ChainedFn<F, T>>) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Runner function signature for asynchronous parameterized tests.
|
|
19
|
+
*
|
|
20
|
+
* @template | {@linkcode Fn} `F` - Source async function under test.
|
|
21
|
+
* @template | {@linkcode NextFn} `T` - Output transformer type, defaults to {@linkcode Identity}.
|
|
22
|
+
*/
|
|
5
23
|
export type _UseAsyncEach_F = <F extends Fn<any, Promise<any>>, T extends NextFn<F> = Identity<F>>(f: F, transform?: T, ...cases: TestArgs<ChainedFn<F, T>>) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Higher-order function returning a test runner for asynchronous parameterized tests.
|
|
26
|
+
*
|
|
27
|
+
* @template | {@linkcode Fn} `F` - Source async function under test.
|
|
28
|
+
* @template | {@linkcode NextFn} `T` - Output transformer type, defaults to {@linkcode Identity}.
|
|
29
|
+
*/
|
|
6
30
|
export type UseAsyncEach_F = <F extends Fn<any, Promise<any>>, T extends NextFn<F> = Identity<F>>(f: F, transform?: T) => (...cases: TestArgs<ChainedFn<F, T>>) => void;
|
|
@@ -2,6 +2,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_utils_sleep = require("../utils/sleep.cjs");
|
|
3
3
|
//#region src/vitest-extended/fakeWaiter.ts
|
|
4
4
|
const buildInvite = (index = 0, ms = 0, times = 1) => `#${index} Wait for ${ms}ms times ${times}`;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a timer-advancing waiter function that supports both fake timers and real delays.
|
|
7
|
+
*
|
|
8
|
+
* @param vi - Vitest utilities instance of type {@linkcode VitestUtils}.
|
|
9
|
+
*
|
|
10
|
+
* @returns An asynchronous waiting function.
|
|
11
|
+
*/
|
|
5
12
|
const createFakeWaiter = (vi) => {
|
|
6
13
|
return async (ms = 0, times = 1) => {
|
|
7
14
|
const check = vi.isFakeTimers();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fakeWaiter.cjs","names":["sleep"],"sources":["../../src/vitest-extended/fakeWaiter.ts"],"sourcesContent":["import type { VitestUtils } from 'vitest';\n\nimport { sleep } from '#utils/sleep';\n\nexport type FakeWaiter1_F = (\n vi: VitestUtils,\n) => (ms?: number, times?: number) => Promise<void>;\n\nexport type FakeWaiter2_F = (\n vi: VitestUtils,\n ms?: number,\n) => (index: number, times?: number) => [string, () => Promise<void>];\n\nexport type FakeWaiter3_F = (\n vi: VitestUtils,\n) => (\n index: number,\n ms?: number,\n times?: number,\n) => [string, () => Promise<void>];\n\nexport type FakeWaiter = FakeWaiter1_F & {\n withDefaultDelay: FakeWaiter2_F;\n all: FakeWaiter3_F;\n};\n\nconst buildInvite = (index = 0, ms = 0, times = 1) =>\n `#${index} Wait for ${ms}ms times ${times}`;\n\nexport const createFakeWaiter: FakeWaiter = vi => {\n return async (ms = 0, times = 1) => {\n const check = vi.isFakeTimers();\n for (let i = 0; i < times; i++) {\n if (check) await vi.advanceTimersByTimeAsync(ms);\n else await sleep(ms);\n }\n };\n};\n\ncreateFakeWaiter.withDefaultDelay = (vi, ms = 0) => {\n return (index, times = 1) => {\n const invite = buildInvite(index, ms, times);\n const fn = () => createFakeWaiter(vi)(ms, times);\n return [invite, fn] as const;\n };\n};\n\ncreateFakeWaiter.all = vi => {\n return (index, ms = 0, times = 1) => {\n const invite = buildInvite(index, ms, times);\n const fn = () => createFakeWaiter(vi)(ms, times);\n return [invite, fn] as const;\n };\n};\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"fakeWaiter.cjs","names":["sleep"],"sources":["../../src/vitest-extended/fakeWaiter.ts"],"sourcesContent":["import type { VitestUtils } from 'vitest';\n\nimport { sleep } from '#utils/sleep';\n\n/**\n * Function creating a waiter using Vitest utilities.\n *\n * @param vi - Vitest utilities object of type {@linkcode VitestUtils}.\n *\n * @returns An async function accepting delay `ms` and repeat `times`.\n */\nexport type FakeWaiter1_F = (\n vi: VitestUtils,\n) => (ms?: number, times?: number) => Promise<void>;\n\n/**\n * Function creating a waiter with a fixed default delay.\n *\n * @param vi - Vitest utilities object of type {@linkcode VitestUtils}.\n * @param ms - Delay in milliseconds.\n *\n * @returns A function taking index and times that returns a test invite and execution callback tuple.\n */\nexport type FakeWaiter2_F = (\n vi: VitestUtils,\n ms?: number,\n) => (index: number, times?: number) => [string, () => Promise<void>];\n\n/**\n * Function creating a waiter accepting index, delay, and repeat count.\n *\n * @param vi - Vitest utilities object of type {@linkcode VitestUtils}.\n *\n * @returns A function taking index, ms, and times that returns a test invite and execution callback tuple.\n */\nexport type FakeWaiter3_F = (\n vi: VitestUtils,\n) => (\n index: number,\n ms?: number,\n times?: number,\n) => [string, () => Promise<void>];\n\n/**\n * Composite fake waiter function with helper properties.\n */\nexport type FakeWaiter = FakeWaiter1_F & {\n withDefaultDelay: FakeWaiter2_F;\n all: FakeWaiter3_F;\n};\n\nconst buildInvite = (index = 0, ms = 0, times = 1) =>\n `#${index} Wait for ${ms}ms times ${times}`;\n\n/**\n * Creates a timer-advancing waiter function that supports both fake timers and real delays.\n *\n * @param vi - Vitest utilities instance of type {@linkcode VitestUtils}.\n *\n * @returns An asynchronous waiting function.\n */\nexport const createFakeWaiter: FakeWaiter = vi => {\n return async (ms = 0, times = 1) => {\n const check = vi.isFakeTimers();\n for (let i = 0; i < times; i++) {\n if (check) await vi.advanceTimersByTimeAsync(ms);\n else await sleep(ms);\n }\n };\n};\n\ncreateFakeWaiter.withDefaultDelay = (vi, ms = 0) => {\n return (index, times = 1) => {\n const invite = buildInvite(index, ms, times);\n const fn = () => createFakeWaiter(vi)(ms, times);\n return [invite, fn] as const;\n };\n};\n\ncreateFakeWaiter.all = vi => {\n return (index, ms = 0, times = 1) => {\n const invite = buildInvite(index, ms, times);\n const fn = () => createFakeWaiter(vi)(ms, times);\n return [invite, fn] as const;\n };\n};\n"],"mappings":";;;AAmDA,MAAM,eAAe,QAAQ,GAAG,KAAK,GAAG,QAAQ,MAC9C,IAAI,MAAM,YAAY,GAAG,WAAW;;;;;;;;AAStC,MAAa,oBAA+B,OAAM;CAChD,OAAO,OAAO,KAAK,GAAG,QAAQ,MAAM;EAClC,MAAM,QAAQ,GAAG,aAAa;EAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,KACzB,IAAI,OAAO,MAAM,GAAG,yBAAyB,EAAE;OAC1C,MAAMA,oBAAAA,MAAM,EAAE;CAEvB;AACF;AAEA,iBAAiB,oBAAoB,IAAI,KAAK,MAAM;CAClD,QAAQ,OAAO,QAAQ,MAAM;EAC3B,MAAM,SAAS,YAAY,OAAO,IAAI,KAAK;EAC3C,MAAM,WAAW,iBAAiB,EAAE,CAAC,CAAC,IAAI,KAAK;EAC/C,OAAO,CAAC,QAAQ,EAAE;CACpB;AACF;AAEA,iBAAiB,OAAM,OAAM;CAC3B,QAAQ,OAAO,KAAK,GAAG,QAAQ,MAAM;EACnC,MAAM,SAAS,YAAY,OAAO,IAAI,KAAK;EAC3C,MAAM,WAAW,iBAAiB,EAAE,CAAC,CAAC,IAAI,KAAK;EAC/C,OAAO,CAAC,QAAQ,EAAE;CACpB;AACF"}
|
|
@@ -1,9 +1,41 @@
|
|
|
1
1
|
import type { VitestUtils } from 'vitest';
|
|
2
|
+
/**
|
|
3
|
+
* Function creating a waiter using Vitest utilities.
|
|
4
|
+
*
|
|
5
|
+
* @param vi - Vitest utilities object of type {@linkcode VitestUtils}.
|
|
6
|
+
*
|
|
7
|
+
* @returns An async function accepting delay `ms` and repeat `times`.
|
|
8
|
+
*/
|
|
2
9
|
export type FakeWaiter1_F = (vi: VitestUtils) => (ms?: number, times?: number) => Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Function creating a waiter with a fixed default delay.
|
|
12
|
+
*
|
|
13
|
+
* @param vi - Vitest utilities object of type {@linkcode VitestUtils}.
|
|
14
|
+
* @param ms - Delay in milliseconds.
|
|
15
|
+
*
|
|
16
|
+
* @returns A function taking index and times that returns a test invite and execution callback tuple.
|
|
17
|
+
*/
|
|
3
18
|
export type FakeWaiter2_F = (vi: VitestUtils, ms?: number) => (index: number, times?: number) => [string, () => Promise<void>];
|
|
19
|
+
/**
|
|
20
|
+
* Function creating a waiter accepting index, delay, and repeat count.
|
|
21
|
+
*
|
|
22
|
+
* @param vi - Vitest utilities object of type {@linkcode VitestUtils}.
|
|
23
|
+
*
|
|
24
|
+
* @returns A function taking index, ms, and times that returns a test invite and execution callback tuple.
|
|
25
|
+
*/
|
|
4
26
|
export type FakeWaiter3_F = (vi: VitestUtils) => (index: number, ms?: number, times?: number) => [string, () => Promise<void>];
|
|
27
|
+
/**
|
|
28
|
+
* Composite fake waiter function with helper properties.
|
|
29
|
+
*/
|
|
5
30
|
export type FakeWaiter = FakeWaiter1_F & {
|
|
6
31
|
withDefaultDelay: FakeWaiter2_F;
|
|
7
32
|
all: FakeWaiter3_F;
|
|
8
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Creates a timer-advancing waiter function that supports both fake timers and real delays.
|
|
36
|
+
*
|
|
37
|
+
* @param vi - Vitest utilities instance of type {@linkcode VitestUtils}.
|
|
38
|
+
*
|
|
39
|
+
* @returns An asynchronous waiting function.
|
|
40
|
+
*/
|
|
9
41
|
export declare const createFakeWaiter: FakeWaiter;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { sleep } from "../utils/sleep.js";
|
|
2
2
|
//#region src/vitest-extended/fakeWaiter.ts
|
|
3
3
|
const buildInvite = (index = 0, ms = 0, times = 1) => `#${index} Wait for ${ms}ms times ${times}`;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a timer-advancing waiter function that supports both fake timers and real delays.
|
|
6
|
+
*
|
|
7
|
+
* @param vi - Vitest utilities instance of type {@linkcode VitestUtils}.
|
|
8
|
+
*
|
|
9
|
+
* @returns An asynchronous waiting function.
|
|
10
|
+
*/
|
|
4
11
|
const createFakeWaiter = (vi) => {
|
|
5
12
|
return async (ms = 0, times = 1) => {
|
|
6
13
|
const check = vi.isFakeTimers();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fakeWaiter.js","names":[],"sources":["../../src/vitest-extended/fakeWaiter.ts"],"sourcesContent":["import type { VitestUtils } from 'vitest';\n\nimport { sleep } from '#utils/sleep';\n\nexport type FakeWaiter1_F = (\n vi: VitestUtils,\n) => (ms?: number, times?: number) => Promise<void>;\n\nexport type FakeWaiter2_F = (\n vi: VitestUtils,\n ms?: number,\n) => (index: number, times?: number) => [string, () => Promise<void>];\n\nexport type FakeWaiter3_F = (\n vi: VitestUtils,\n) => (\n index: number,\n ms?: number,\n times?: number,\n) => [string, () => Promise<void>];\n\nexport type FakeWaiter = FakeWaiter1_F & {\n withDefaultDelay: FakeWaiter2_F;\n all: FakeWaiter3_F;\n};\n\nconst buildInvite = (index = 0, ms = 0, times = 1) =>\n `#${index} Wait for ${ms}ms times ${times}`;\n\nexport const createFakeWaiter: FakeWaiter = vi => {\n return async (ms = 0, times = 1) => {\n const check = vi.isFakeTimers();\n for (let i = 0; i < times; i++) {\n if (check) await vi.advanceTimersByTimeAsync(ms);\n else await sleep(ms);\n }\n };\n};\n\ncreateFakeWaiter.withDefaultDelay = (vi, ms = 0) => {\n return (index, times = 1) => {\n const invite = buildInvite(index, ms, times);\n const fn = () => createFakeWaiter(vi)(ms, times);\n return [invite, fn] as const;\n };\n};\n\ncreateFakeWaiter.all = vi => {\n return (index, ms = 0, times = 1) => {\n const invite = buildInvite(index, ms, times);\n const fn = () => createFakeWaiter(vi)(ms, times);\n return [invite, fn] as const;\n };\n};\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"fakeWaiter.js","names":[],"sources":["../../src/vitest-extended/fakeWaiter.ts"],"sourcesContent":["import type { VitestUtils } from 'vitest';\n\nimport { sleep } from '#utils/sleep';\n\n/**\n * Function creating a waiter using Vitest utilities.\n *\n * @param vi - Vitest utilities object of type {@linkcode VitestUtils}.\n *\n * @returns An async function accepting delay `ms` and repeat `times`.\n */\nexport type FakeWaiter1_F = (\n vi: VitestUtils,\n) => (ms?: number, times?: number) => Promise<void>;\n\n/**\n * Function creating a waiter with a fixed default delay.\n *\n * @param vi - Vitest utilities object of type {@linkcode VitestUtils}.\n * @param ms - Delay in milliseconds.\n *\n * @returns A function taking index and times that returns a test invite and execution callback tuple.\n */\nexport type FakeWaiter2_F = (\n vi: VitestUtils,\n ms?: number,\n) => (index: number, times?: number) => [string, () => Promise<void>];\n\n/**\n * Function creating a waiter accepting index, delay, and repeat count.\n *\n * @param vi - Vitest utilities object of type {@linkcode VitestUtils}.\n *\n * @returns A function taking index, ms, and times that returns a test invite and execution callback tuple.\n */\nexport type FakeWaiter3_F = (\n vi: VitestUtils,\n) => (\n index: number,\n ms?: number,\n times?: number,\n) => [string, () => Promise<void>];\n\n/**\n * Composite fake waiter function with helper properties.\n */\nexport type FakeWaiter = FakeWaiter1_F & {\n withDefaultDelay: FakeWaiter2_F;\n all: FakeWaiter3_F;\n};\n\nconst buildInvite = (index = 0, ms = 0, times = 1) =>\n `#${index} Wait for ${ms}ms times ${times}`;\n\n/**\n * Creates a timer-advancing waiter function that supports both fake timers and real delays.\n *\n * @param vi - Vitest utilities instance of type {@linkcode VitestUtils}.\n *\n * @returns An asynchronous waiting function.\n */\nexport const createFakeWaiter: FakeWaiter = vi => {\n return async (ms = 0, times = 1) => {\n const check = vi.isFakeTimers();\n for (let i = 0; i < times; i++) {\n if (check) await vi.advanceTimersByTimeAsync(ms);\n else await sleep(ms);\n }\n };\n};\n\ncreateFakeWaiter.withDefaultDelay = (vi, ms = 0) => {\n return (index, times = 1) => {\n const invite = buildInvite(index, ms, times);\n const fn = () => createFakeWaiter(vi)(ms, times);\n return [invite, fn] as const;\n };\n};\n\ncreateFakeWaiter.all = vi => {\n return (index, ms = 0, times = 1) => {\n const invite = buildInvite(index, ms, times);\n const fn = () => createFakeWaiter(vi)(ms, times);\n return [invite, fn] as const;\n };\n};\n"],"mappings":";;AAmDA,MAAM,eAAe,QAAQ,GAAG,KAAK,GAAG,QAAQ,MAC9C,IAAI,MAAM,YAAY,GAAG,WAAW;;;;;;;;AAStC,MAAa,oBAA+B,OAAM;CAChD,OAAO,OAAO,KAAK,GAAG,QAAQ,MAAM;EAClC,MAAM,QAAQ,GAAG,aAAa;EAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,KACzB,IAAI,OAAO,MAAM,GAAG,yBAAyB,EAAE;OAC1C,MAAM,MAAM,EAAE;CAEvB;AACF;AAEA,iBAAiB,oBAAoB,IAAI,KAAK,MAAM;CAClD,QAAQ,OAAO,QAAQ,MAAM;EAC3B,MAAM,SAAS,YAAY,OAAO,IAAI,KAAK;EAC3C,MAAM,WAAW,iBAAiB,EAAE,CAAC,CAAC,IAAI,KAAK;EAC/C,OAAO,CAAC,QAAQ,EAAE;CACpB;AACF;AAEA,iBAAiB,OAAM,OAAM;CAC3B,QAAQ,OAAO,KAAK,GAAG,QAAQ,MAAM;EACnC,MAAM,SAAS,YAAY,OAAO,IAAI,KAAK;EAC3C,MAAM,WAAW,iBAAiB,EAAE,CAAC,CAAC,IAAI,KAAK;EAC/C,OAAO,CAAC,QAAQ,EAAE;CACpB;AACF"}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/vitest-extended/fixtures/coverage.ts
|
|
3
|
+
/**
|
|
4
|
+
* Test fixture constant.
|
|
5
|
+
*/
|
|
3
6
|
const expected = "done!";
|
|
7
|
+
/**
|
|
8
|
+
* Test fixture returning a constant string.
|
|
9
|
+
*
|
|
10
|
+
* @returns Expected constant string.
|
|
11
|
+
*/
|
|
4
12
|
const noArgs = () => expected;
|
|
13
|
+
/**
|
|
14
|
+
* Test fixture adding multiple numbers together.
|
|
15
|
+
*/
|
|
5
16
|
const addMany = (...numbers) => numbers.reduce((acc, value) => acc + value, 0);
|
|
6
17
|
//#endregion
|
|
7
18
|
exports.addMany = addMany;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverage.cjs","names":[],"sources":["../../../src/vitest-extended/fixtures/coverage.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"coverage.cjs","names":[],"sources":["../../../src/vitest-extended/fixtures/coverage.ts"],"sourcesContent":["/**\n * Test fixture constant.\n */\nexport const expected = 'done!';\n\n/**\n * Test fixture returning a constant string.\n *\n * @returns Expected constant string.\n */\nexport const noArgs = () => expected;\n\ntype AddMany = (...params: number[]) => number;\n\n/**\n * Test fixture adding multiple numbers together.\n */\nexport const addMany: AddMany = (...numbers) =>\n numbers.reduce((acc, value) => acc + value, 0);\n"],"mappings":";;;;;AAGA,MAAa,WAAW;;;;;;AAOxB,MAAa,eAAe;;;;AAO5B,MAAa,WAAoB,GAAG,YAClC,QAAQ,QAAQ,KAAK,UAAU,MAAM,OAAO,CAAC"}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
//#region src/vitest-extended/fixtures/coverage.ts
|
|
2
|
+
/**
|
|
3
|
+
* Test fixture constant.
|
|
4
|
+
*/
|
|
2
5
|
const expected = "done!";
|
|
6
|
+
/**
|
|
7
|
+
* Test fixture returning a constant string.
|
|
8
|
+
*
|
|
9
|
+
* @returns Expected constant string.
|
|
10
|
+
*/
|
|
3
11
|
const noArgs = () => expected;
|
|
12
|
+
/**
|
|
13
|
+
* Test fixture adding multiple numbers together.
|
|
14
|
+
*/
|
|
4
15
|
const addMany = (...numbers) => numbers.reduce((acc, value) => acc + value, 0);
|
|
5
16
|
//#endregion
|
|
6
17
|
export { addMany, expected, noArgs };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverage.js","names":[],"sources":["../../../src/vitest-extended/fixtures/coverage.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"coverage.js","names":[],"sources":["../../../src/vitest-extended/fixtures/coverage.ts"],"sourcesContent":["/**\n * Test fixture constant.\n */\nexport const expected = 'done!';\n\n/**\n * Test fixture returning a constant string.\n *\n * @returns Expected constant string.\n */\nexport const noArgs = () => expected;\n\ntype AddMany = (...params: number[]) => number;\n\n/**\n * Test fixture adding multiple numbers together.\n */\nexport const addMany: AddMany = (...numbers) =>\n numbers.reduce((acc, value) => acc + value, 0);\n"],"mappings":";;;;AAGA,MAAa,WAAW;;;;;;AAOxB,MAAa,eAAe;;;;AAO5B,MAAa,WAAoB,GAAG,YAClC,QAAQ,QAAQ,KAAK,UAAU,MAAM,OAAO,CAAC"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/vitest-extended/fixtures/partialCall.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Creates a partially applied function for a single object parameter function.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
6
|
+
* @template | {@linkcode object} `T` - Partial argument shape.
|
|
7
|
+
* @template `U` - Full argument shape extending `T`.
|
|
8
|
+
* @template `R` - Return type.
|
|
9
|
+
*
|
|
10
|
+
* @param f - Target function.
|
|
11
|
+
* @param headArgs - Initial partial argument values.
|
|
12
|
+
*
|
|
13
|
+
* @returns Function accepting remaining arguments.
|
|
9
14
|
*/
|
|
10
15
|
function partialCallO(f, headArgs) {
|
|
11
16
|
return (remainArgs) => f({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partialCall.cjs","names":[],"sources":["../../../src/vitest-extended/fixtures/partialCall.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"partialCall.cjs","names":[],"sources":["../../../src/vitest-extended/fixtures/partialCall.ts"],"sourcesContent":["/**\n * Creates a partially applied function for a single object parameter function.\n *\n * @template | {@linkcode object} `T` - Partial argument shape.\n * @template `U` - Full argument shape extending `T`.\n * @template `R` - Return type.\n *\n * @param f - Target function.\n * @param headArgs - Initial partial argument values.\n *\n * @returns Function accepting remaining arguments.\n */\nexport function partialCallO<T extends object, U extends T, R>(\n f: (arg: U) => R,\n headArgs?: T,\n) {\n return (remainArgs: Omit<U, keyof T>) =>\n f({ ...remainArgs, ...headArgs } as U);\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAgB,aACd,GACA,UACA;CACA,QAAQ,eACN,EAAE;EAAE,GAAG;EAAY,GAAG;CAAS,CAAM;AACzC"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
//#region src/vitest-extended/fixtures/partialCall.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Creates a partially applied function for a single object parameter function.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
5
|
+
* @template | {@linkcode object} `T` - Partial argument shape.
|
|
6
|
+
* @template `U` - Full argument shape extending `T`.
|
|
7
|
+
* @template `R` - Return type.
|
|
8
|
+
*
|
|
9
|
+
* @param f - Target function.
|
|
10
|
+
* @param headArgs - Initial partial argument values.
|
|
11
|
+
*
|
|
12
|
+
* @returns Function accepting remaining arguments.
|
|
8
13
|
*/
|
|
9
14
|
function partialCallO(f, headArgs) {
|
|
10
15
|
return (remainArgs) => f({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partialCall.js","names":[],"sources":["../../../src/vitest-extended/fixtures/partialCall.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"partialCall.js","names":[],"sources":["../../../src/vitest-extended/fixtures/partialCall.ts"],"sourcesContent":["/**\n * Creates a partially applied function for a single object parameter function.\n *\n * @template | {@linkcode object} `T` - Partial argument shape.\n * @template `U` - Full argument shape extending `T`.\n * @template `R` - Return type.\n *\n * @param f - Target function.\n * @param headArgs - Initial partial argument values.\n *\n * @returns Function accepting remaining arguments.\n */\nexport function partialCallO<T extends object, U extends T, R>(\n f: (arg: U) => R,\n headArgs?: T,\n) {\n return (remainArgs: Omit<U, keyof T>) =>\n f({ ...remainArgs, ...headArgs } as U);\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAgB,aACd,GACA,UACA;CACA,QAAQ,eACN,EAAE;EAAE,GAAG;EAAY,GAAG;CAAS,CAAM;AACzC"}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/vitest-extended/fixtures/toUpper.ts
|
|
3
|
+
/**
|
|
4
|
+
* Converts a string to uppercase.
|
|
5
|
+
*
|
|
6
|
+
* @template `S` - String type.
|
|
7
|
+
*
|
|
8
|
+
* @param str - Input string.
|
|
9
|
+
*
|
|
10
|
+
* @returns Uppercase string of type `Uppercase<S>`.
|
|
11
|
+
*/
|
|
3
12
|
const _toUpper = (str) => {
|
|
4
13
|
return str.toUpperCase();
|
|
5
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Converts an array of strings to uppercase.
|
|
17
|
+
*
|
|
18
|
+
* @template `S` - String array type.
|
|
19
|
+
*
|
|
20
|
+
* @param strs - Array of strings.
|
|
21
|
+
*
|
|
22
|
+
* @returns Array of uppercase strings.
|
|
23
|
+
*/
|
|
6
24
|
const toUpper = (...strs) => {
|
|
7
25
|
return strs.map(_toUpper);
|
|
8
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toUpper.cjs","names":[],"sources":["../../../src/vitest-extended/fixtures/toUpper.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"toUpper.cjs","names":[],"sources":["../../../src/vitest-extended/fixtures/toUpper.ts"],"sourcesContent":["/**\n * Converts a string to uppercase.\n *\n * @template `S` - String type.\n *\n * @param str - Input string.\n *\n * @returns Uppercase string of type `Uppercase<S>`.\n */\nexport const _toUpper = <S extends string>(str: S) => {\n const out = str.toUpperCase();\n return out as Uppercase<S>;\n};\n\n/**\n * Converts an array of strings to uppercase.\n *\n * @template `S` - String array type.\n *\n * @param strs - Array of strings.\n *\n * @returns Array of uppercase strings.\n */\nexport const toUpper = <S extends string[]>(...strs: S) => {\n return strs.map(_toUpper);\n};\n"],"mappings":";;;;;;;;;;;AASA,MAAa,YAA8B,QAAW;CAEpD,OADY,IAAI,YACP;AACX;;;;;;;;;;AAWA,MAAa,WAA+B,GAAG,SAAY;CACzD,OAAO,KAAK,IAAI,QAAQ;AAC1B"}
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
//#region src/vitest-extended/fixtures/toUpper.ts
|
|
2
|
+
/**
|
|
3
|
+
* Converts a string to uppercase.
|
|
4
|
+
*
|
|
5
|
+
* @template `S` - String type.
|
|
6
|
+
*
|
|
7
|
+
* @param str - Input string.
|
|
8
|
+
*
|
|
9
|
+
* @returns Uppercase string of type `Uppercase<S>`.
|
|
10
|
+
*/
|
|
2
11
|
const _toUpper = (str) => {
|
|
3
12
|
return str.toUpperCase();
|
|
4
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Converts an array of strings to uppercase.
|
|
16
|
+
*
|
|
17
|
+
* @template `S` - String array type.
|
|
18
|
+
*
|
|
19
|
+
* @param strs - Array of strings.
|
|
20
|
+
*
|
|
21
|
+
* @returns Array of uppercase strings.
|
|
22
|
+
*/
|
|
5
23
|
const toUpper = (...strs) => {
|
|
6
24
|
return strs.map(_toUpper);
|
|
7
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toUpper.js","names":[],"sources":["../../../src/vitest-extended/fixtures/toUpper.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"toUpper.js","names":[],"sources":["../../../src/vitest-extended/fixtures/toUpper.ts"],"sourcesContent":["/**\n * Converts a string to uppercase.\n *\n * @template `S` - String type.\n *\n * @param str - Input string.\n *\n * @returns Uppercase string of type `Uppercase<S>`.\n */\nexport const _toUpper = <S extends string>(str: S) => {\n const out = str.toUpperCase();\n return out as Uppercase<S>;\n};\n\n/**\n * Converts an array of strings to uppercase.\n *\n * @template `S` - String array type.\n *\n * @param strs - Array of strings.\n *\n * @returns Array of uppercase strings.\n */\nexport const toUpper = <S extends string[]>(...strs: S) => {\n return strs.map(_toUpper);\n};\n"],"mappings":";;;;;;;;;;AASA,MAAa,YAA8B,QAAW;CAEpD,OADY,IAAI,YACP;AACX;;;;;;;;;;AAWA,MAAa,WAA+B,GAAG,SAAY;CACzD,OAAO,KAAK,IAAI,QAAQ;AAC1B"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/vitest-extended/fixtures/vitest.ts
|
|
3
|
+
/**
|
|
4
|
+
* Flag indicating whether tests are executed within the VS Code Vitest extension.
|
|
5
|
+
*/
|
|
3
6
|
const IS_EXTENSION = process.env.VITEST_VSCODE === "true";
|
|
4
7
|
//#endregion
|
|
5
8
|
exports.IS_EXTENSION = IS_EXTENSION;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.cjs","names":[],"sources":["../../../src/vitest-extended/fixtures/vitest.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"vitest.cjs","names":[],"sources":["../../../src/vitest-extended/fixtures/vitest.ts"],"sourcesContent":["/**\n * Flag indicating whether tests are executed within the VS Code Vitest extension.\n */\nexport const IS_EXTENSION = process.env.VITEST_VSCODE === 'true';\n"],"mappings":";;;;;AAGA,MAAa,eAAe,QAAQ,IAAI,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","names":[],"sources":["../../../src/vitest-extended/fixtures/vitest.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"vitest.js","names":[],"sources":["../../../src/vitest-extended/fixtures/vitest.ts"],"sourcesContent":["/**\n * Flag indicating whether tests are executed within the VS Code Vitest extension.\n */\nexport const IS_EXTENSION = process.env.VITEST_VSCODE === 'true';\n"],"mappings":";;;;AAGA,MAAa,eAAe,QAAQ,IAAI,kBAAkB"}
|
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/vitest-extended/fixtures/zod.ts
|
|
3
|
+
/**
|
|
4
|
+
* Converts a Zod schema into a synchronous type-guard validation function.
|
|
5
|
+
*
|
|
6
|
+
* @template | {@linkcode Any} `T` - Zod schema type.
|
|
7
|
+
*
|
|
8
|
+
* @param zod - Zod schema instance.
|
|
9
|
+
*
|
|
10
|
+
* @returns Type guard validation function.
|
|
11
|
+
*/
|
|
3
12
|
const transformZodToFunction = (zod) => {
|
|
4
13
|
const f = (arg) => {
|
|
5
14
|
return zod.safeParse(arg).success;
|
|
6
15
|
};
|
|
7
16
|
return f;
|
|
8
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Alias for {@linkcode transformZodToFunction}.
|
|
20
|
+
*/
|
|
9
21
|
const transformZTF = transformZodToFunction;
|
|
22
|
+
/**
|
|
23
|
+
* Converts a Zod schema into an asynchronous boolean validation function.
|
|
24
|
+
*
|
|
25
|
+
* @param zod - Zod schema instance of type {@linkcode Any}.
|
|
26
|
+
*
|
|
27
|
+
* @returns Async validation function returning a boolean.
|
|
28
|
+
*/
|
|
10
29
|
const transformZodToFunctionAsync = (zod) => {
|
|
11
30
|
const f = async (arg) => {
|
|
12
31
|
return (await zod.safeParseAsync(arg)).success;
|
|
13
32
|
};
|
|
14
33
|
return f;
|
|
15
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Alias for {@linkcode transformZodToFunctionAsync}.
|
|
37
|
+
*/
|
|
16
38
|
const transformZTFAsync = transformZodToFunctionAsync;
|
|
17
39
|
//#endregion
|
|
18
40
|
exports.transformZTF = transformZTF;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.cjs","names":[],"sources":["../../../src/vitest-extended/fixtures/zod.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport type Any = z.ZodTypeAny;\n\nexport const transformZodToFunction = <T extends Any>(zod: T) => {\n type Z = z.infer<T>;\n\n const f = (arg: any): arg is Z => {\n return zod.safeParse(arg).success;\n };\n\n return f;\n};\n\nexport const transformZTF = transformZodToFunction;\n\nexport const transformZodToFunctionAsync = (zod: Any) => {\n const f = async (arg: any) => {\n const _zod = await zod.safeParseAsync(arg);\n return _zod.success;\n };\n\n return f;\n};\n\nexport const transformZTFAsync = transformZodToFunctionAsync;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod.cjs","names":[],"sources":["../../../src/vitest-extended/fixtures/zod.ts"],"sourcesContent":["import { z } from 'zod';\n\n/**\n * Type alias for any Zod schema.\n */\nexport type Any = z.ZodTypeAny;\n\n/**\n * Converts a Zod schema into a synchronous type-guard validation function.\n *\n * @template | {@linkcode Any} `T` - Zod schema type.\n *\n * @param zod - Zod schema instance.\n *\n * @returns Type guard validation function.\n */\nexport const transformZodToFunction = <T extends Any>(zod: T) => {\n type Z = z.infer<T>;\n\n const f = (arg: any): arg is Z => {\n return zod.safeParse(arg).success;\n };\n\n return f;\n};\n\n/**\n * Alias for {@linkcode transformZodToFunction}.\n */\nexport const transformZTF = transformZodToFunction;\n\n/**\n * Converts a Zod schema into an asynchronous boolean validation function.\n *\n * @param zod - Zod schema instance of type {@linkcode Any}.\n *\n * @returns Async validation function returning a boolean.\n */\nexport const transformZodToFunctionAsync = (zod: Any) => {\n const f = async (arg: any) => {\n const _zod = await zod.safeParseAsync(arg);\n return _zod.success;\n };\n\n return f;\n};\n\n/**\n * Alias for {@linkcode transformZodToFunctionAsync}.\n */\nexport const transformZTFAsync = transformZodToFunctionAsync;\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,0BAAyC,QAAW;CAG/D,MAAM,KAAK,QAAuB;EAChC,OAAO,IAAI,UAAU,GAAG,CAAC,CAAC;CAC5B;CAEA,OAAO;AACT;;;;AAKA,MAAa,eAAe;;;;;;;;AAS5B,MAAa,+BAA+B,QAAa;CACvD,MAAM,IAAI,OAAO,QAAa;EAE5B,QAAO,MADY,IAAI,eAAe,GAAG,EAAA,CAC7B;CACd;CAEA,OAAO;AACT;;;;AAKA,MAAa,oBAAoB"}
|
|
@@ -1,17 +1,39 @@
|
|
|
1
1
|
//#region src/vitest-extended/fixtures/zod.ts
|
|
2
|
+
/**
|
|
3
|
+
* Converts a Zod schema into a synchronous type-guard validation function.
|
|
4
|
+
*
|
|
5
|
+
* @template | {@linkcode Any} `T` - Zod schema type.
|
|
6
|
+
*
|
|
7
|
+
* @param zod - Zod schema instance.
|
|
8
|
+
*
|
|
9
|
+
* @returns Type guard validation function.
|
|
10
|
+
*/
|
|
2
11
|
const transformZodToFunction = (zod) => {
|
|
3
12
|
const f = (arg) => {
|
|
4
13
|
return zod.safeParse(arg).success;
|
|
5
14
|
};
|
|
6
15
|
return f;
|
|
7
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Alias for {@linkcode transformZodToFunction}.
|
|
19
|
+
*/
|
|
8
20
|
const transformZTF = transformZodToFunction;
|
|
21
|
+
/**
|
|
22
|
+
* Converts a Zod schema into an asynchronous boolean validation function.
|
|
23
|
+
*
|
|
24
|
+
* @param zod - Zod schema instance of type {@linkcode Any}.
|
|
25
|
+
*
|
|
26
|
+
* @returns Async validation function returning a boolean.
|
|
27
|
+
*/
|
|
9
28
|
const transformZodToFunctionAsync = (zod) => {
|
|
10
29
|
const f = async (arg) => {
|
|
11
30
|
return (await zod.safeParseAsync(arg)).success;
|
|
12
31
|
};
|
|
13
32
|
return f;
|
|
14
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Alias for {@linkcode transformZodToFunctionAsync}.
|
|
36
|
+
*/
|
|
15
37
|
const transformZTFAsync = transformZodToFunctionAsync;
|
|
16
38
|
//#endregion
|
|
17
39
|
export { transformZTF, transformZTFAsync, transformZodToFunction, transformZodToFunctionAsync };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.js","names":[],"sources":["../../../src/vitest-extended/fixtures/zod.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport type Any = z.ZodTypeAny;\n\nexport const transformZodToFunction = <T extends Any>(zod: T) => {\n type Z = z.infer<T>;\n\n const f = (arg: any): arg is Z => {\n return zod.safeParse(arg).success;\n };\n\n return f;\n};\n\nexport const transformZTF = transformZodToFunction;\n\nexport const transformZodToFunctionAsync = (zod: Any) => {\n const f = async (arg: any) => {\n const _zod = await zod.safeParseAsync(arg);\n return _zod.success;\n };\n\n return f;\n};\n\nexport const transformZTFAsync = transformZodToFunctionAsync;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod.js","names":[],"sources":["../../../src/vitest-extended/fixtures/zod.ts"],"sourcesContent":["import { z } from 'zod';\n\n/**\n * Type alias for any Zod schema.\n */\nexport type Any = z.ZodTypeAny;\n\n/**\n * Converts a Zod schema into a synchronous type-guard validation function.\n *\n * @template | {@linkcode Any} `T` - Zod schema type.\n *\n * @param zod - Zod schema instance.\n *\n * @returns Type guard validation function.\n */\nexport const transformZodToFunction = <T extends Any>(zod: T) => {\n type Z = z.infer<T>;\n\n const f = (arg: any): arg is Z => {\n return zod.safeParse(arg).success;\n };\n\n return f;\n};\n\n/**\n * Alias for {@linkcode transformZodToFunction}.\n */\nexport const transformZTF = transformZodToFunction;\n\n/**\n * Converts a Zod schema into an asynchronous boolean validation function.\n *\n * @param zod - Zod schema instance of type {@linkcode Any}.\n *\n * @returns Async validation function returning a boolean.\n */\nexport const transformZodToFunctionAsync = (zod: Any) => {\n const f = async (arg: any) => {\n const _zod = await zod.safeParseAsync(arg);\n return _zod.success;\n };\n\n return f;\n};\n\n/**\n * Alias for {@linkcode transformZodToFunctionAsync}.\n */\nexport const transformZTFAsync = transformZodToFunctionAsync;\n"],"mappings":";;;;;;;;;;AAgBA,MAAa,0BAAyC,QAAW;CAG/D,MAAM,KAAK,QAAuB;EAChC,OAAO,IAAI,UAAU,GAAG,CAAC,CAAC;CAC5B;CAEA,OAAO;AACT;;;;AAKA,MAAa,eAAe;;;;;;;;AAS5B,MAAa,+BAA+B,QAAa;CACvD,MAAM,IAAI,OAAO,QAAa;EAE5B,QAAO,MADY,IAAI,eAAe,GAAG,EAAA,CAC7B;CACd;CAEA,OAAO;AACT;;;;AAKA,MAAa,oBAAoB"}
|