@bemedev/dev-utils 1.3.1 → 1.4.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.
Files changed (55) hide show
  1. package/README.md +62 -83
  2. package/lib/build-tests/buildPackageJson.cjs.map +1 -1
  3. package/lib/build-tests/buildPackageJson.js.map +1 -1
  4. package/lib/build-tests/cli/test.cjs.map +1 -1
  5. package/lib/build-tests/cli/test.js.map +1 -1
  6. package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
  7. package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
  8. package/lib/build-tests/imports/create.cjs.map +1 -1
  9. package/lib/build-tests/imports/create.js.map +1 -1
  10. package/lib/build-tests/imports/helper.cjs.map +1 -1
  11. package/lib/build-tests/imports/helper.js.map +1 -1
  12. package/lib/plugins/hmr.cjs +14 -23
  13. package/lib/plugins/hmr.cjs.map +1 -1
  14. package/lib/plugins/hmr.d.ts +5 -15
  15. package/lib/plugins/hmr.js +14 -23
  16. package/lib/plugins/hmr.js.map +1 -1
  17. package/lib/plugins/suppressWarnings.cjs.map +1 -1
  18. package/lib/plugins/suppressWarnings.js.map +1 -1
  19. package/lib/rolldown-config/config.cjs.map +1 -1
  20. package/lib/rolldown-config/config.js.map +1 -1
  21. package/lib/rolldown-config/helpers.cjs.map +1 -1
  22. package/lib/rolldown-config/helpers.js.map +1 -1
  23. package/lib/rolldown-config/input.cjs.map +1 -1
  24. package/lib/rolldown-config/input.js.map +1 -1
  25. package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
  26. package/lib/rolldown-config/plugins/circulars.js.map +1 -1
  27. package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
  28. package/lib/rolldown-config/plugins/clean.js.map +1 -1
  29. package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
  30. package/lib/rolldown-config/plugins/externals.js.map +1 -1
  31. package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
  32. package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
  33. package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
  34. package/lib/rolldown-config/plugins/typescript.fast.cjs.map +1 -1
  35. package/lib/rolldown-config/plugins/typescript.fast.js.map +1 -1
  36. package/lib/rolldown-config/plugins/typescript.js.map +1 -1
  37. package/lib/utils/bemedev/globals/utils/expandFn.cjs.map +1 -1
  38. package/lib/utils/bemedev/globals/utils/expandFn.js.map +1 -1
  39. package/lib/vitest-exclude/vitest.cjs.map +1 -1
  40. package/lib/vitest-exclude/vitest.js.map +1 -1
  41. package/lib/vitest-extended/createTests.cjs.map +1 -1
  42. package/lib/vitest-extended/createTests.js.map +1 -1
  43. package/lib/vitest-extended/done.cjs.map +1 -1
  44. package/lib/vitest-extended/done.js.map +1 -1
  45. package/lib/vitest-extended/each/error.cjs.map +1 -1
  46. package/lib/vitest-extended/each/error.js.map +1 -1
  47. package/lib/vitest-extended/each/pass.cjs.map +1 -1
  48. package/lib/vitest-extended/each/pass.js.map +1 -1
  49. package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
  50. package/lib/vitest-extended/fakeWaiter.js.map +1 -1
  51. package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
  52. package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
  53. package/lib/vitest-extended/isFunction.cjs.map +1 -1
  54. package/lib/vitest-extended/isFunction.js.map +1 -1
  55. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import type { Plugin } from 'vitest/config';\n\nimport { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\n\n/**\n * Creates include arrays for test and coverage files from glob patterns.\n *\n * @param args - Glob patterns to ignore for test and coverage files.\n * @param root - Optional root directory path.\n *\n * @returns An object with resolved `files` and `coverage` string arrays.\n */\nexport async function create(args: Args[1] = {}, root?: string) {\n const firsts = {\n patternTest: testPattern(root),\n patternCov: defaultCovPattern(root),\n };\n\n return create.withPattern(firsts, args, root);\n}\n\n/**\n * Creates include arrays using custom test and coverage glob patterns.\n *\n * @param patterns - Custom test and coverage pattern object.\n * @param patterns.patternTest - Glob pattern for test files.\n * @param patterns.patternCov - Glob pattern for coverage files.\n * @param args - Ignore options for tests and coverage.\n * @param root - Optional root directory path.\n *\n * @returns An object with resolved `files` and `coverage` string arrays.\n */\ncreate.withPattern = async (\n { patternTest, patternCov }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n root?: string,\n) => {\n const files = await buildInclude(\n patternTest ?? testPattern(root),\n ignoreTestFiles,\n root,\n );\n const coverage = await buildInclude(\n patternCov ?? defaultCovPattern(root),\n ignoreCoverageFiles,\n root,\n );\n return { files, coverage };\n};\n\n/**\n * Vitest plugin to configure test and coverage file inclusion via glob patterns.\n *\n * @param args - Globs to ignore for test and coverage files.\n *\n * @returns Vitest plugin of type {@linkcode Plugin}.\n */\nexport function exclude(args: Args[1] = {}) {\n return {\n name,\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const patternCov = defaultCovPattern(root);\n const patternTest = testPattern(root);\n\n const { ignoreCoverageFiles, ignoreTestFiles } = args;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: { ...coverage, include: all.coverage },\n },\n };\n },\n } as Plugin;\n}\n\n/**\n * Vitest plugin to configure test and coverage file inclusion with custom search patterns.\n *\n * @param patterns - Custom test and coverage glob patterns.\n * @param ignore - Globs to exclude.\n *\n * @returns Vitest plugin of type {@linkcode Plugin}.\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n) => {\n return {\n name,\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: { ...coverage, include: all.coverage },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;;;AAkBA,eAAsB,OAAO,OAAgB,CAAC,GAAG,MAAe;CAC9D,MAAM,SAAS;EACb,aAAa,YAAY,IAAI;EAC7B,YAAY,kBAAkB,IAAI;CACpC;CAEA,OAAO,OAAO,YAAY,QAAQ,MAAM,IAAI;AAC9C;;;;;;;;;;;;AAaA,OAAO,cAAc,OACnB,EAAE,aAAa,eAAiC,CAAC,GACjD,EAAE,iBAAiB,wBAAiC,CAAC,GACrD,SACG;CAWH,OAAO;EAAE,OAAA,MAVW,aAClB,eAAe,YAAY,IAAI,GAC/B,iBACA,IACF;EAMgB,UAAA,MALO,aACrB,cAAc,kBAAkB,IAAI,GACpC,qBACA,IACF;CACyB;AAC3B;;;;;;;;AASA,SAAgB,QAAQ,OAAgB,CAAC,GAAG;CAC1C,OAAO;EACL;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,aAAa,kBAAkB,IAAI;GACzC,MAAM,cAAc,YAAY,IAAI;GAEpC,MAAM,EAAE,qBAAqB,oBAAoB;GAEjD,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;GAAW,GAC1B;IAAE;IAAqB;GAAgB,GACvC,IACF;GAEA,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MAAE,GAAG;MAAU,SAAS,IAAI;KAAS;IACjD;GACF;EACF;CACF;AACF;;;;;;;;;AAUA,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;CACH,OAAO;EACL;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;GAAW,GAC1B;IAAE;IAAqB;GAAgB,GACvC,IACF;GAEA,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MAAE,GAAG;MAAU,SAAS,IAAI;KAAS;IACjD;GACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import type { Plugin } from 'vitest/config';\n\nimport { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport { buildInclude, defaultCovPattern, testPattern } from './vitest.utils';\n\n/**\n * Creates include arrays for test and coverage files from glob patterns.\n *\n * @param args - Glob patterns to ignore for test and coverage files.\n * @param root - Optional root directory path.\n *\n * @returns An object with resolved `files` and `coverage` string arrays.\n */\nexport async function create(args: Args[1] = {}, root?: string) {\n const firsts = {\n patternTest: testPattern(root),\n patternCov: defaultCovPattern(root),\n };\n\n return create.withPattern(firsts, args, root);\n}\n\n/**\n * Creates include arrays using custom test and coverage glob patterns.\n *\n * @param patterns - Custom test and coverage pattern object.\n * @param patterns.patternTest - Glob pattern for test files.\n * @param patterns.patternCov - Glob pattern for coverage files.\n * @param args - Ignore options for tests and coverage.\n * @param root - Optional root directory path.\n *\n * @returns An object with resolved `files` and `coverage` string arrays.\n */\ncreate.withPattern = async (\n { patternTest, patternCov }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n root?: string,\n) => {\n const files = await buildInclude(\n patternTest ?? testPattern(root),\n ignoreTestFiles,\n root,\n );\n const coverage = await buildInclude(\n patternCov ?? defaultCovPattern(root),\n ignoreCoverageFiles,\n root,\n );\n return { files, coverage };\n};\n\n/**\n * Vitest plugin to configure test and coverage file inclusion via glob patterns.\n *\n * @param args - Globs to ignore for test and coverage files.\n *\n * @returns Vitest plugin of type {@linkcode Plugin}.\n */\nexport function exclude(args: Args[1] = {}) {\n return {\n name,\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const patternCov = defaultCovPattern(root);\n const patternTest = testPattern(root);\n\n const { ignoreCoverageFiles, ignoreTestFiles } = args;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: { ...coverage, include: all.coverage },\n },\n };\n },\n } as Plugin;\n}\n\n/**\n * Vitest plugin to configure test and coverage file inclusion with custom search patterns.\n *\n * @param patterns - Custom test and coverage glob patterns.\n * @param ignore - Globs to exclude.\n *\n * @returns Vitest plugin of type {@linkcode Plugin}.\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n) => {\n return {\n name,\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: { ...coverage, include: all.coverage },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;;;AAcA,eAAsB,OAAO,OAAgB,CAAC,GAAG,MAAe;CAC9D,MAAM,SAAS;EACb,aAAa,YAAY,IAAI;EAC7B,YAAY,kBAAkB,IAAI;CACpC;CAEA,OAAO,OAAO,YAAY,QAAQ,MAAM,IAAI;AAC9C;;;;;;;;;;;;AAaA,OAAO,cAAc,OACnB,EAAE,aAAa,eAAiC,CAAC,GACjD,EAAE,iBAAiB,wBAAiC,CAAC,GACrD,SACG;CAWH,OAAO;EAAE,OAAA,MAVW,aAClB,eAAe,YAAY,IAAI,GAC/B,iBACA,IACF;EAMgB,UAAA,MALO,aACrB,cAAc,kBAAkB,IAAI,GACpC,qBACA,IACF;CACyB;AAC3B;;;;;;;;AASA,SAAgB,QAAQ,OAAgB,CAAC,GAAG;CAC1C,OAAO;EACL;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,aAAa,kBAAkB,IAAI;GACzC,MAAM,cAAc,YAAY,IAAI;GAEpC,MAAM,EAAE,qBAAqB,oBAAoB;GAEjD,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;GAAW,GAC1B;IAAE;IAAqB;GAAgB,GACvC,IACF;GAEA,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MAAE,GAAG;MAAU,SAAS,IAAI;KAAS;IACjD;GACF;EACF;CACF;AACF;;;;;;;;;AAUA,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;CACH,OAAO;EACL;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;GAAW,GAC1B;IAAE;IAAqB;GAAgB,GACvC,IACF;GAEA,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MAAE,GAAG;MAAU,SAAS,IAAI;KAAS;IACjD;GACF;EACF;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"createTests.cjs","names":["useTFA","useErrorAsyncEach","toStringFlat","useEachAsync","vi"],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { useTFA } from './acceptation';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport { useEachAsync } from './each/pass';\nimport { toStringFlat } from './toStringFlat';\n\nexport type { _CreateTests_F };\n\nconst _create: _CreateTests_F = (func, transform, toError, name) => {\n return {\n acceptation: () => useTFA(func, name),\n\n fails: (...cases) => {\n const length = cases.length;\n\n return () => {\n const useTests = useErrorAsyncEach(\n func,\n transform as any,\n toError,\n );\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, error }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, error };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n\n success: (...cases) => {\n const length = cases.length;\n return () => {\n const useTests = useEachAsync(func as any, transform);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, expected, test }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, expected, test };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n };\n};\n\n/**\n * Creates structured test suites with acceptation, success, and failure runners.\n *\n * @template `F0` - Function parameters array type.\n * @template `F1` - Function return value type.\n * @template `F2` - Transformed return value type, defaults to `F1`.\n *\n * @param func - Function under test of type {@linkcode Fn}.\n * @param args - Configuration options.\n * @param args.transform - Optional output transformer of type {@linkcode Fn}.\n * @param args.toError - Optional error mapping function of type {@linkcode Fn}.\n *\n * @returns Test suite object with acceptation, success, and fails methods.\n *\n * @example\n * ```ts\n * const useTests = createTests(add);\n * useTests.success({\n * invite: 'For : 1,2,3',\n * parameters: [[1, 2, 3]],\n * expected: 6,\n * })();\n * ```\n */\nexport const createTests = <F0 extends any[], F1, F2 = F1>(\n func: Fn<F0, F1>,\n args?: {\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const { transform, toError } = args || {};\n return _create(func, transform, toError);\n};\n\n/**\n * Creates structured test suites with an async instantiation or mock implementation.\n *\n * @template `F0` - Function parameters array type.\n * @template `F1` - Function return value type.\n * @template `F2` - Transformed return value type, defaults to `F1`.\n *\n * @param f - Fallback or default function of type {@linkcode Fn}.\n * @param options - Configuration options for instantiation and formatting.\n * @param options.instanciation - Async function returning the target implementation.\n * @param options.name - Name identifier for test descriptions.\n * @param options.transform - Optional output transformer.\n * @param options.toError - Optional error mapping function.\n *\n * @returns Test suite object with acceptation, success, and fails methods.\n */\ncreateTests.withImplementation = <F0 extends any[], F1, F2 = F1>(\n f: Fn<NoInfer<F0>, NoInfer<F1>>,\n {\n instanciation,\n name,\n transform,\n toError,\n }: {\n instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;\n name: string;\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const func = vi.fn(f);\n\n if (instanciation) {\n beforeAll(async () => {\n const impl = await instanciation();\n func.mockImplementation(impl);\n });\n }\n\n return _create(func, transform, toError, name);\n};\n\ncreateTests.withoutImplementation = createTests;\n"],"mappings":";;;;;;;AAWA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;CAClE,OAAO;EACL,mBAAmBA,oCAAAA,OAAO,MAAM,IAAI;EAEpC,QAAQ,GAAG,UAAU;GACnB,MAAM,SAAS,MAAM;GAErB,aAAa;IAeX,OAdiBC,mCAAAA,kBACf,MACA,WACA,OAWY,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,SAAS,UAAU;KAGjD,OAAO;MADO,QAAA,IADKC,qCAAAA,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;KACzB;IACX,CAGsB,CAAC;GAC3B;EACF;EAEA,UAAU,GAAG,UAAU;GACrB,MAAM,SAAS,MAAM;GACrB,aAAa;IAWX,OAViBC,kCAAAA,aAAa,MAAa,SAU7B,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,UAAU,QAAQ,UAAU;KAG1D,OAAO;MADO,QAAA,IADKD,qCAAAA,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;MAAU;KACnC;IACX,CAGsB,CAAC;GAC3B;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,eACX,MACA,SAIG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC;CACxC,OAAO,QAAQ,MAAM,WAAW,OAAO;AACzC;;;;;;;;;;;;;;;;;AAkBA,YAAY,sBACV,GACA,EACE,eACA,MACA,WACA,cAOC;CACH,MAAM,OAAOE,OAAAA,GAAG,GAAG,CAAC;CAEpB,IAAI,eACF,CAAA,GAAA,OAAA,UAAA,CAAU,YAAY;EACpB,MAAM,OAAO,MAAM,cAAc;EACjC,KAAK,mBAAmB,IAAI;CAC9B,CAAC;CAGH,OAAO,QAAQ,MAAM,WAAW,SAAS,IAAI;AAC/C;AAEA,YAAY,wBAAwB"}
1
+ {"version":3,"file":"createTests.cjs","names":["useTFA","useErrorAsyncEach","toStringFlat","useEachAsync","vi"],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { useTFA } from './acceptation';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport { useEachAsync } from './each/pass';\nimport { toStringFlat } from './toStringFlat';\n\nexport type { _CreateTests_F };\n\nconst _create: _CreateTests_F = (func, transform, toError, name) => {\n return {\n acceptation: () => useTFA(func, name),\n\n fails: (...cases) => {\n const length = cases.length;\n\n return () => {\n const useTests = useErrorAsyncEach(func, transform as any, toError);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, error }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, error };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n\n success: (...cases) => {\n const length = cases.length;\n return () => {\n const useTests = useEachAsync(func as any, transform);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, expected, test }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, expected, test };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n };\n};\n\n/**\n * Creates structured test suites with acceptation, success, and failure runners.\n *\n * @template `F0` - Function parameters array type.\n * @template `F1` - Function return value type.\n * @template `F2` - Transformed return value type, defaults to `F1`.\n *\n * @param func - Function under test of type {@linkcode Fn}.\n * @param args - Configuration options.\n * @param args.transform - Optional output transformer of type {@linkcode Fn}.\n * @param args.toError - Optional error mapping function of type {@linkcode Fn}.\n *\n * @returns Test suite object with acceptation, success, and fails methods.\n *\n * @example\n * ```ts\n * const useTests = createTests(add);\n * useTests.success({\n * invite: 'For : 1,2,3',\n * parameters: [[1, 2, 3]],\n * expected: 6,\n * })();\n * ```\n */\nexport const createTests = <F0 extends any[], F1, F2 = F1>(\n func: Fn<F0, F1>,\n args?: { transform?: Fn<[Awaited<F1>], F2>; toError?: Fn<F0, string | undefined> },\n) => {\n const { transform, toError } = args || {};\n return _create(func, transform, toError);\n};\n\n/**\n * Creates structured test suites with an async instantiation or mock implementation.\n *\n * @template `F0` - Function parameters array type.\n * @template `F1` - Function return value type.\n * @template `F2` - Transformed return value type, defaults to `F1`.\n *\n * @param f - Fallback or default function of type {@linkcode Fn}.\n * @param options - Configuration options for instantiation and formatting.\n * @param options.instanciation - Async function returning the target implementation.\n * @param options.name - Name identifier for test descriptions.\n * @param options.transform - Optional output transformer.\n * @param options.toError - Optional error mapping function.\n *\n * @returns Test suite object with acceptation, success, and fails methods.\n */\ncreateTests.withImplementation = <F0 extends any[], F1, F2 = F1>(\n f: Fn<NoInfer<F0>, NoInfer<F1>>,\n {\n instanciation,\n name,\n transform,\n toError,\n }: {\n instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;\n name: string;\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const func = vi.fn(f);\n\n if (instanciation) {\n beforeAll(async () => {\n const impl = await instanciation();\n func.mockImplementation(impl);\n });\n }\n\n return _create(func, transform, toError, name);\n};\n\ncreateTests.withoutImplementation = createTests;\n"],"mappings":";;;;;;;AAWA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;CAClE,OAAO;EACL,mBAAmBA,oCAAAA,OAAO,MAAM,IAAI;EAEpC,QAAQ,GAAG,UAAU;GACnB,MAAM,SAAS,MAAM;GAErB,aAAa;IAWX,OAViBC,mCAAAA,kBAAkB,MAAM,WAAkB,OAU7C,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,SAAS,UAAU;KAGjD,OAAO;MADO,QAAA,IADKC,qCAAAA,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;KACzB;IACX,CAGsB,CAAC;GAC3B;EACF;EAEA,UAAU,GAAG,UAAU;GACrB,MAAM,SAAS,MAAM;GACrB,aAAa;IAWX,OAViBC,kCAAAA,aAAa,MAAa,SAU7B,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,UAAU,QAAQ,UAAU;KAG1D,OAAO;MADO,QAAA,IADKD,qCAAAA,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;MAAU;KACnC;IACX,CAGsB,CAAC;GAC3B;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,eACX,MACA,SACG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC;CACxC,OAAO,QAAQ,MAAM,WAAW,OAAO;AACzC;;;;;;;;;;;;;;;;;AAkBA,YAAY,sBACV,GACA,EACE,eACA,MACA,WACA,cAOC;CACH,MAAM,OAAOE,OAAAA,GAAG,GAAG,CAAC;CAEpB,IAAI,eACF,CAAA,GAAA,OAAA,UAAA,CAAU,YAAY;EACpB,MAAM,OAAO,MAAM,cAAc;EACjC,KAAK,mBAAmB,IAAI;CAC9B,CAAC;CAGH,OAAO,QAAQ,MAAM,WAAW,SAAS,IAAI;AAC/C;AAEA,YAAY,wBAAwB"}
@@ -1 +1 @@
1
- {"version":3,"file":"createTests.js","names":[],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { useTFA } from './acceptation';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport { useEachAsync } from './each/pass';\nimport { toStringFlat } from './toStringFlat';\n\nexport type { _CreateTests_F };\n\nconst _create: _CreateTests_F = (func, transform, toError, name) => {\n return {\n acceptation: () => useTFA(func, name),\n\n fails: (...cases) => {\n const length = cases.length;\n\n return () => {\n const useTests = useErrorAsyncEach(\n func,\n transform as any,\n toError,\n );\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, error }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, error };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n\n success: (...cases) => {\n const length = cases.length;\n return () => {\n const useTests = useEachAsync(func as any, transform);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, expected, test }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, expected, test };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n };\n};\n\n/**\n * Creates structured test suites with acceptation, success, and failure runners.\n *\n * @template `F0` - Function parameters array type.\n * @template `F1` - Function return value type.\n * @template `F2` - Transformed return value type, defaults to `F1`.\n *\n * @param func - Function under test of type {@linkcode Fn}.\n * @param args - Configuration options.\n * @param args.transform - Optional output transformer of type {@linkcode Fn}.\n * @param args.toError - Optional error mapping function of type {@linkcode Fn}.\n *\n * @returns Test suite object with acceptation, success, and fails methods.\n *\n * @example\n * ```ts\n * const useTests = createTests(add);\n * useTests.success({\n * invite: 'For : 1,2,3',\n * parameters: [[1, 2, 3]],\n * expected: 6,\n * })();\n * ```\n */\nexport const createTests = <F0 extends any[], F1, F2 = F1>(\n func: Fn<F0, F1>,\n args?: {\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const { transform, toError } = args || {};\n return _create(func, transform, toError);\n};\n\n/**\n * Creates structured test suites with an async instantiation or mock implementation.\n *\n * @template `F0` - Function parameters array type.\n * @template `F1` - Function return value type.\n * @template `F2` - Transformed return value type, defaults to `F1`.\n *\n * @param f - Fallback or default function of type {@linkcode Fn}.\n * @param options - Configuration options for instantiation and formatting.\n * @param options.instanciation - Async function returning the target implementation.\n * @param options.name - Name identifier for test descriptions.\n * @param options.transform - Optional output transformer.\n * @param options.toError - Optional error mapping function.\n *\n * @returns Test suite object with acceptation, success, and fails methods.\n */\ncreateTests.withImplementation = <F0 extends any[], F1, F2 = F1>(\n f: Fn<NoInfer<F0>, NoInfer<F1>>,\n {\n instanciation,\n name,\n transform,\n toError,\n }: {\n instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;\n name: string;\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const func = vi.fn(f);\n\n if (instanciation) {\n beforeAll(async () => {\n const impl = await instanciation();\n func.mockImplementation(impl);\n });\n }\n\n return _create(func, transform, toError, name);\n};\n\ncreateTests.withoutImplementation = createTests;\n"],"mappings":";;;;;;AAWA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;CAClE,OAAO;EACL,mBAAmB,OAAO,MAAM,IAAI;EAEpC,QAAQ,GAAG,UAAU;GACnB,MAAM,SAAS,MAAM;GAErB,aAAa;IAeX,OAdiB,kBACf,MACA,WACA,OAWY,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,SAAS,UAAU;KAGjD,OAAO;MADO,QAAA,IADK,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;KACzB;IACX,CAGsB,CAAC;GAC3B;EACF;EAEA,UAAU,GAAG,UAAU;GACrB,MAAM,SAAS,MAAM;GACrB,aAAa;IAWX,OAViB,aAAa,MAAa,SAU7B,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,UAAU,QAAQ,UAAU;KAG1D,OAAO;MADO,QAAA,IADK,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;MAAU;KACnC;IACX,CAGsB,CAAC;GAC3B;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,eACX,MACA,SAIG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC;CACxC,OAAO,QAAQ,MAAM,WAAW,OAAO;AACzC;;;;;;;;;;;;;;;;;AAkBA,YAAY,sBACV,GACA,EACE,eACA,MACA,WACA,cAOC;CACH,MAAM,OAAO,GAAG,GAAG,CAAC;CAEpB,IAAI,eACF,UAAU,YAAY;EACpB,MAAM,OAAO,MAAM,cAAc;EACjC,KAAK,mBAAmB,IAAI;CAC9B,CAAC;CAGH,OAAO,QAAQ,MAAM,WAAW,SAAS,IAAI;AAC/C;AAEA,YAAY,wBAAwB"}
1
+ {"version":3,"file":"createTests.js","names":[],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { useTFA } from './acceptation';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport { useEachAsync } from './each/pass';\nimport { toStringFlat } from './toStringFlat';\n\nexport type { _CreateTests_F };\n\nconst _create: _CreateTests_F = (func, transform, toError, name) => {\n return {\n acceptation: () => useTFA(func, name),\n\n fails: (...cases) => {\n const length = cases.length;\n\n return () => {\n const useTests = useErrorAsyncEach(func, transform as any, toError);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, error }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, error };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n\n success: (...cases) => {\n const length = cases.length;\n return () => {\n const useTests = useEachAsync(func as any, transform);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, expected, test }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, expected, test };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n };\n};\n\n/**\n * Creates structured test suites with acceptation, success, and failure runners.\n *\n * @template `F0` - Function parameters array type.\n * @template `F1` - Function return value type.\n * @template `F2` - Transformed return value type, defaults to `F1`.\n *\n * @param func - Function under test of type {@linkcode Fn}.\n * @param args - Configuration options.\n * @param args.transform - Optional output transformer of type {@linkcode Fn}.\n * @param args.toError - Optional error mapping function of type {@linkcode Fn}.\n *\n * @returns Test suite object with acceptation, success, and fails methods.\n *\n * @example\n * ```ts\n * const useTests = createTests(add);\n * useTests.success({\n * invite: 'For : 1,2,3',\n * parameters: [[1, 2, 3]],\n * expected: 6,\n * })();\n * ```\n */\nexport const createTests = <F0 extends any[], F1, F2 = F1>(\n func: Fn<F0, F1>,\n args?: { transform?: Fn<[Awaited<F1>], F2>; toError?: Fn<F0, string | undefined> },\n) => {\n const { transform, toError } = args || {};\n return _create(func, transform, toError);\n};\n\n/**\n * Creates structured test suites with an async instantiation or mock implementation.\n *\n * @template `F0` - Function parameters array type.\n * @template `F1` - Function return value type.\n * @template `F2` - Transformed return value type, defaults to `F1`.\n *\n * @param f - Fallback or default function of type {@linkcode Fn}.\n * @param options - Configuration options for instantiation and formatting.\n * @param options.instanciation - Async function returning the target implementation.\n * @param options.name - Name identifier for test descriptions.\n * @param options.transform - Optional output transformer.\n * @param options.toError - Optional error mapping function.\n *\n * @returns Test suite object with acceptation, success, and fails methods.\n */\ncreateTests.withImplementation = <F0 extends any[], F1, F2 = F1>(\n f: Fn<NoInfer<F0>, NoInfer<F1>>,\n {\n instanciation,\n name,\n transform,\n toError,\n }: {\n instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;\n name: string;\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const func = vi.fn(f);\n\n if (instanciation) {\n beforeAll(async () => {\n const impl = await instanciation();\n func.mockImplementation(impl);\n });\n }\n\n return _create(func, transform, toError, name);\n};\n\ncreateTests.withoutImplementation = createTests;\n"],"mappings":";;;;;;AAWA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;CAClE,OAAO;EACL,mBAAmB,OAAO,MAAM,IAAI;EAEpC,QAAQ,GAAG,UAAU;GACnB,MAAM,SAAS,MAAM;GAErB,aAAa;IAWX,OAViB,kBAAkB,MAAM,WAAkB,OAU7C,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,SAAS,UAAU;KAGjD,OAAO;MADO,QAAA,IADK,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;KACzB;IACX,CAGsB,CAAC;GAC3B;EACF;EAEA,UAAU,GAAG,UAAU;GACrB,MAAM,SAAS,MAAM;GACrB,aAAa;IAWX,OAViB,aAAa,MAAa,SAU7B,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,UAAU,QAAQ,UAAU;KAG1D,OAAO;MADO,QAAA,IADK,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;MAAU;KACnC;IACX,CAGsB,CAAC;GAC3B;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,eACX,MACA,SACG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC;CACxC,OAAO,QAAQ,MAAM,WAAW,OAAO;AACzC;;;;;;;;;;;;;;;;;AAkBA,YAAY,sBACV,GACA,EACE,eACA,MACA,WACA,cAOC;CACH,MAAM,OAAO,GAAG,GAAG,CAAC;CAEpB,IAAI,eACF,UAAU,YAAY;EACpB,MAAM,OAAO,MAAM,cAAc;EACjC,KAAK,mBAAmB,IAAI;CAC9B,CAAC;CAGH,OAAO,QAAQ,MAAM,WAAW,SAAS,IAAI;AAC/C;AAEA,YAAY,wBAAwB"}
@@ -1 +1 @@
1
- {"version":3,"file":"done.cjs","names":["sleep","test"],"sources":["../../src/vitest-extended/done.ts"],"sourcesContent":["import { expect, test, type TestOptions } from 'vitest';\n\nimport { sleep } from '#utils/sleep';\n\nimport type { TestDoneFunction } from './types';\n\nconst useDone = (ms = 0) => {\n let executed = false;\n const done = () => (executed = true);\n\n const testDone = async () => {\n await sleep(ms);\n expect(executed).toBe(true);\n };\n\n return { done, testDone };\n};\n\nconst min100 = (ms = 0) => Math.max(100, ms);\n\n// #region Preparation\nconst getTimeout = (options?: TestOptions | number) => {\n if (typeof options === 'number') return min100(options);\n return min100(options?.timeout);\n};\n\nconst objectify = (\n options?: TestOptions | number,\n): [TestOptions, number] => {\n const _timeout = getTimeout(options);\n const timeout = _timeout + 100;\n\n let _options = { timeout };\n if (!(typeof options === 'number')) {\n _options = { ...options, timeout };\n }\n\n return [_options, _timeout];\n};\n// #endregion\n\n/**\n * Build a test with a done callback function and a timeout.\n *\n * @param invite - The description of the test.\n * @param fn - Test callback function of type {@linkcode TestDoneFunction}.\n * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.\n *\n * @returns A Vitest test execution result.\n */\nexport const doneTest = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a test expected to fail with a done callback function and a timeout.\n *\n * @param invite - The description of the test.\n * @param fn - Test callback function of type {@linkcode TestDoneFunction}.\n * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.\n *\n * @returns A Vitest test execution result.\n */\ndoneTest.fails = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.fails(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a concurrent test with a done callback function and a timeout.\n *\n * @param invite - The description of the test.\n * @param fn - Test callback function of type {@linkcode TestDoneFunction}.\n * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.\n *\n * @returns A Vitest test execution result.\n */\ndoneTest.concurrent = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.concurrent(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n"],"mappings":";;;;AAMA,MAAM,WAAW,KAAK,MAAM;CAC1B,IAAI,WAAW;CACf,MAAM,aAAc,WAAW;CAE/B,MAAM,WAAW,YAAY;EAC3B,MAAMA,oBAAAA,MAAM,EAAE;EACd,CAAA,GAAA,OAAA,OAAA,CAAO,QAAQ,CAAC,CAAC,KAAK,IAAI;CAC5B;CAEA,OAAO;EAAE;EAAM;CAAS;AAC1B;AAEA,MAAM,UAAU,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE;AAG3C,MAAM,cAAc,YAAmC;CACrD,IAAI,OAAO,YAAY,UAAU,OAAO,OAAO,OAAO;CACtD,OAAO,OAAO,SAAS,OAAO;AAChC;AAEA,MAAM,aACJ,YAC0B;CAC1B,MAAM,WAAW,WAAW,OAAO;CACnC,MAAM,UAAU,WAAW;CAE3B,IAAI,WAAW,EAAE,QAAQ;CACzB,IAAI,EAAE,OAAO,YAAY,WACvB,WAAW;EAAE,GAAG;EAAS;CAAQ;CAGnC,OAAO,CAAC,UAAU,QAAQ;AAC5B;;;;;;;;;;AAYA,MAAa,YACX,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,QAAA,GAAOC,OAAAA,KAAAA,CAAK,QAAQ,gBAAgB;EAClC,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;;AAWA,SAAS,SACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAOA,OAAAA,KAAK,MAAM,QAAQ,gBAAgB;EACxC,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;;AAWA,SAAS,cACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAOA,OAAAA,KAAK,WAAW,QAAQ,gBAAgB;EAC7C,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH"}
1
+ {"version":3,"file":"done.cjs","names":["sleep","test"],"sources":["../../src/vitest-extended/done.ts"],"sourcesContent":["import { expect, test, type TestOptions } from 'vitest';\n\nimport { sleep } from '#utils/sleep';\n\nimport type { TestDoneFunction } from './types';\n\nconst useDone = (ms = 0) => {\n let executed = false;\n const done = () => (executed = true);\n\n const testDone = async () => {\n await sleep(ms);\n expect(executed).toBe(true);\n };\n\n return { done, testDone };\n};\n\nconst min100 = (ms = 0) => Math.max(100, ms);\n\n// #region Preparation\nconst getTimeout = (options?: TestOptions | number) => {\n if (typeof options === 'number') return min100(options);\n return min100(options?.timeout);\n};\n\nconst objectify = (options?: TestOptions | number): [TestOptions, number] => {\n const _timeout = getTimeout(options);\n const timeout = _timeout + 100;\n\n let _options = { timeout };\n if (!(typeof options === 'number')) {\n _options = { ...options, timeout };\n }\n\n return [_options, _timeout];\n};\n// #endregion\n\n/**\n * Build a test with a done callback function and a timeout.\n *\n * @param invite - The description of the test.\n * @param fn - Test callback function of type {@linkcode TestDoneFunction}.\n * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.\n *\n * @returns A Vitest test execution result.\n */\nexport const doneTest = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a test expected to fail with a done callback function and a timeout.\n *\n * @param invite - The description of the test.\n * @param fn - Test callback function of type {@linkcode TestDoneFunction}.\n * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.\n *\n * @returns A Vitest test execution result.\n */\ndoneTest.fails = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.fails(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a concurrent test with a done callback function and a timeout.\n *\n * @param invite - The description of the test.\n * @param fn - Test callback function of type {@linkcode TestDoneFunction}.\n * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.\n *\n * @returns A Vitest test execution result.\n */\ndoneTest.concurrent = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.concurrent(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n"],"mappings":";;;;AAMA,MAAM,WAAW,KAAK,MAAM;CAC1B,IAAI,WAAW;CACf,MAAM,aAAc,WAAW;CAE/B,MAAM,WAAW,YAAY;EAC3B,MAAMA,oBAAAA,MAAM,EAAE;EACd,CAAA,GAAA,OAAA,OAAA,CAAO,QAAQ,CAAC,CAAC,KAAK,IAAI;CAC5B;CAEA,OAAO;EAAE;EAAM;CAAS;AAC1B;AAEA,MAAM,UAAU,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE;AAG3C,MAAM,cAAc,YAAmC;CACrD,IAAI,OAAO,YAAY,UAAU,OAAO,OAAO,OAAO;CACtD,OAAO,OAAO,SAAS,OAAO;AAChC;AAEA,MAAM,aAAa,YAA0D;CAC3E,MAAM,WAAW,WAAW,OAAO;CACnC,MAAM,UAAU,WAAW;CAE3B,IAAI,WAAW,EAAE,QAAQ;CACzB,IAAI,EAAE,OAAO,YAAY,WACvB,WAAW;EAAE,GAAG;EAAS;CAAQ;CAGnC,OAAO,CAAC,UAAU,QAAQ;AAC5B;;;;;;;;;;AAYA,MAAa,YACX,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,QAAA,GAAOC,OAAAA,KAAAA,CAAK,QAAQ,gBAAgB;EAClC,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;;AAWA,SAAS,SACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAOA,OAAAA,KAAK,MAAM,QAAQ,gBAAgB;EACxC,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;;AAWA,SAAS,cACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAOA,OAAAA,KAAK,WAAW,QAAQ,gBAAgB;EAC7C,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"done.js","names":[],"sources":["../../src/vitest-extended/done.ts"],"sourcesContent":["import { expect, test, type TestOptions } from 'vitest';\n\nimport { sleep } from '#utils/sleep';\n\nimport type { TestDoneFunction } from './types';\n\nconst useDone = (ms = 0) => {\n let executed = false;\n const done = () => (executed = true);\n\n const testDone = async () => {\n await sleep(ms);\n expect(executed).toBe(true);\n };\n\n return { done, testDone };\n};\n\nconst min100 = (ms = 0) => Math.max(100, ms);\n\n// #region Preparation\nconst getTimeout = (options?: TestOptions | number) => {\n if (typeof options === 'number') return min100(options);\n return min100(options?.timeout);\n};\n\nconst objectify = (\n options?: TestOptions | number,\n): [TestOptions, number] => {\n const _timeout = getTimeout(options);\n const timeout = _timeout + 100;\n\n let _options = { timeout };\n if (!(typeof options === 'number')) {\n _options = { ...options, timeout };\n }\n\n return [_options, _timeout];\n};\n// #endregion\n\n/**\n * Build a test with a done callback function and a timeout.\n *\n * @param invite - The description of the test.\n * @param fn - Test callback function of type {@linkcode TestDoneFunction}.\n * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.\n *\n * @returns A Vitest test execution result.\n */\nexport const doneTest = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a test expected to fail with a done callback function and a timeout.\n *\n * @param invite - The description of the test.\n * @param fn - Test callback function of type {@linkcode TestDoneFunction}.\n * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.\n *\n * @returns A Vitest test execution result.\n */\ndoneTest.fails = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.fails(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a concurrent test with a done callback function and a timeout.\n *\n * @param invite - The description of the test.\n * @param fn - Test callback function of type {@linkcode TestDoneFunction}.\n * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.\n *\n * @returns A Vitest test execution result.\n */\ndoneTest.concurrent = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.concurrent(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n"],"mappings":";;;AAMA,MAAM,WAAW,KAAK,MAAM;CAC1B,IAAI,WAAW;CACf,MAAM,aAAc,WAAW;CAE/B,MAAM,WAAW,YAAY;EAC3B,MAAM,MAAM,EAAE;EACd,OAAO,QAAQ,CAAC,CAAC,KAAK,IAAI;CAC5B;CAEA,OAAO;EAAE;EAAM;CAAS;AAC1B;AAEA,MAAM,UAAU,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE;AAG3C,MAAM,cAAc,YAAmC;CACrD,IAAI,OAAO,YAAY,UAAU,OAAO,OAAO,OAAO;CACtD,OAAO,OAAO,SAAS,OAAO;AAChC;AAEA,MAAM,aACJ,YAC0B;CAC1B,MAAM,WAAW,WAAW,OAAO;CACnC,MAAM,UAAU,WAAW;CAE3B,IAAI,WAAW,EAAE,QAAQ;CACzB,IAAI,EAAE,OAAO,YAAY,WACvB,WAAW;EAAE,GAAG;EAAS;CAAQ;CAGnC,OAAO,CAAC,UAAU,QAAQ;AAC5B;;;;;;;;;;AAYA,MAAa,YACX,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAO,KAAK,QAAQ,gBAAgB;EAClC,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;;AAWA,SAAS,SACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAO,KAAK,MAAM,QAAQ,gBAAgB;EACxC,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;;AAWA,SAAS,cACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAO,KAAK,WAAW,QAAQ,gBAAgB;EAC7C,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH"}
1
+ {"version":3,"file":"done.js","names":[],"sources":["../../src/vitest-extended/done.ts"],"sourcesContent":["import { expect, test, type TestOptions } from 'vitest';\n\nimport { sleep } from '#utils/sleep';\n\nimport type { TestDoneFunction } from './types';\n\nconst useDone = (ms = 0) => {\n let executed = false;\n const done = () => (executed = true);\n\n const testDone = async () => {\n await sleep(ms);\n expect(executed).toBe(true);\n };\n\n return { done, testDone };\n};\n\nconst min100 = (ms = 0) => Math.max(100, ms);\n\n// #region Preparation\nconst getTimeout = (options?: TestOptions | number) => {\n if (typeof options === 'number') return min100(options);\n return min100(options?.timeout);\n};\n\nconst objectify = (options?: TestOptions | number): [TestOptions, number] => {\n const _timeout = getTimeout(options);\n const timeout = _timeout + 100;\n\n let _options = { timeout };\n if (!(typeof options === 'number')) {\n _options = { ...options, timeout };\n }\n\n return [_options, _timeout];\n};\n// #endregion\n\n/**\n * Build a test with a done callback function and a timeout.\n *\n * @param invite - The description of the test.\n * @param fn - Test callback function of type {@linkcode TestDoneFunction}.\n * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.\n *\n * @returns A Vitest test execution result.\n */\nexport const doneTest = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a test expected to fail with a done callback function and a timeout.\n *\n * @param invite - The description of the test.\n * @param fn - Test callback function of type {@linkcode TestDoneFunction}.\n * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.\n *\n * @returns A Vitest test execution result.\n */\ndoneTest.fails = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.fails(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a concurrent test with a done callback function and a timeout.\n *\n * @param invite - The description of the test.\n * @param fn - Test callback function of type {@linkcode TestDoneFunction}.\n * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.\n *\n * @returns A Vitest test execution result.\n */\ndoneTest.concurrent = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.concurrent(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n"],"mappings":";;;AAMA,MAAM,WAAW,KAAK,MAAM;CAC1B,IAAI,WAAW;CACf,MAAM,aAAc,WAAW;CAE/B,MAAM,WAAW,YAAY;EAC3B,MAAM,MAAM,EAAE;EACd,OAAO,QAAQ,CAAC,CAAC,KAAK,IAAI;CAC5B;CAEA,OAAO;EAAE;EAAM;CAAS;AAC1B;AAEA,MAAM,UAAU,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE;AAG3C,MAAM,cAAc,YAAmC;CACrD,IAAI,OAAO,YAAY,UAAU,OAAO,OAAO,OAAO;CACtD,OAAO,OAAO,SAAS,OAAO;AAChC;AAEA,MAAM,aAAa,YAA0D;CAC3E,MAAM,WAAW,WAAW,OAAO;CACnC,MAAM,UAAU,WAAW;CAE3B,IAAI,WAAW,EAAE,QAAQ;CACzB,IAAI,EAAE,OAAO,YAAY,WACvB,WAAW;EAAE,GAAG;EAAS;CAAQ;CAGnC,OAAO,CAAC,UAAU,QAAQ;AAC5B;;;;;;;;;;AAYA,MAAa,YACX,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAO,KAAK,QAAQ,gBAAgB;EAClC,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;;AAWA,SAAS,SACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAO,KAAK,MAAM,QAAQ,gBAAgB;EACxC,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;;AAWA,SAAS,cACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAO,KAAK,WAAW,QAAQ,gBAAgB;EAC7C,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"error.cjs","names":["identity","toArrayVitest","expect"],"sources":["../../../src/vitest-extended/each/error.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport { identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type { _UseErrorEach_F, UseErrorEach_F } from './error.types';\n\n/**\n * Runs error assertions for asynchronous test cases concurrently.\n */\nexport const useErrorAsyncEachCases: _UseErrorEach_F = (\n f,\n transform = identity as any,\n toError = () => undefined,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest.error(cases))(\n '%s',\n async (_, args, _error) => {\n const actual = async () => {\n const out = await f(...args);\n return transform(out);\n };\n const check = _error === undefined;\n const error = check ? toError(...args) : _error;\n\n await expect(actual).rejects.toThrowError(error);\n },\n );\n};\n\n/**\n * Higher-order function returning a test runner for asynchronous error assertions.\n *\n * @param f - Function to test.\n * @param transform - Optional transformer applied to the resolved return value.\n * @param toError - Optional function computing expected error message from arguments.\n *\n * @returns Function accepting error test cases to execute.\n */\nexport const useErrorAsyncEach: UseErrorEach_F = (\n f,\n transform,\n toError,\n) => {\n return (...cases) =>\n useErrorAsyncEachCases(f, transform, toError, ...cases);\n};\n"],"mappings":";;;;;;;;AASA,MAAa,0BACX,GACA,YAAYA,iCAAAA,UACZ,gBAAgB,KAAA,GAChB,GAAG,UACA;CACH,OAAA,KAAK,WAAW,KAAKC,gCAAAA,cAAc,MAAM,KAAK,CAAC,CAAC,CAC9C,MACA,OAAO,GAAG,MAAM,WAAW;EACzB,MAAM,SAAS,YAAY;GAEzB,OAAO,UAAU,MADC,EAAE,GAAG,IAAI,CACP;EACtB;EAEA,MAAM,QADQ,WAAW,KAAA,IACH,QAAQ,GAAG,IAAI,IAAI;EAEzC,OAAA,GAAMC,OAAAA,OAAAA,CAAO,MAAM,CAAC,CAAC,QAAQ,aAAa,KAAK;CACjD,CACF;AACF;;;;;;;;;;AAWA,MAAa,qBACX,GACA,WACA,YACG;CACH,QAAQ,GAAG,UACT,uBAAuB,GAAG,WAAW,SAAS,GAAG,KAAK;AAC1D"}
1
+ {"version":3,"file":"error.cjs","names":["identity","toArrayVitest","expect"],"sources":["../../../src/vitest-extended/each/error.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport { identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type { _UseErrorEach_F, UseErrorEach_F } from './error.types';\n\n/**\n * Runs error assertions for asynchronous test cases concurrently.\n */\nexport const useErrorAsyncEachCases: _UseErrorEach_F = (\n f,\n transform = identity as any,\n toError = () => undefined,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest.error(cases))('%s', async (_, args, _error) => {\n const actual = async () => {\n const out = await f(...args);\n return transform(out);\n };\n const check = _error === undefined;\n const error = check ? toError(...args) : _error;\n\n await expect(actual).rejects.toThrowError(error);\n });\n};\n\n/**\n * Higher-order function returning a test runner for asynchronous error assertions.\n *\n * @param f - Function to test.\n * @param transform - Optional transformer applied to the resolved return value.\n * @param toError - Optional function computing expected error message from arguments.\n *\n * @returns Function accepting error test cases to execute.\n */\nexport const useErrorAsyncEach: UseErrorEach_F = (f, transform, toError) => {\n return (...cases) => useErrorAsyncEachCases(f, transform, toError, ...cases);\n};\n"],"mappings":";;;;;;;;AASA,MAAa,0BACX,GACA,YAAYA,iCAAAA,UACZ,gBAAgB,KAAA,GAChB,GAAG,UACA;CACH,OAAA,KAAK,WAAW,KAAKC,gCAAAA,cAAc,MAAM,KAAK,CAAC,CAAC,CAAC,MAAM,OAAO,GAAG,MAAM,WAAW;EAChF,MAAM,SAAS,YAAY;GAEzB,OAAO,UAAU,MADC,EAAE,GAAG,IAAI,CACP;EACtB;EAEA,MAAM,QADQ,WAAW,KAAA,IACH,QAAQ,GAAG,IAAI,IAAI;EAEzC,OAAA,GAAMC,OAAAA,OAAAA,CAAO,MAAM,CAAC,CAAC,QAAQ,aAAa,KAAK;CACjD,CAAC;AACH;;;;;;;;;;AAWA,MAAa,qBAAqC,GAAG,WAAW,YAAY;CAC1E,QAAQ,GAAG,UAAU,uBAAuB,GAAG,WAAW,SAAS,GAAG,KAAK;AAC7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","names":[],"sources":["../../../src/vitest-extended/each/error.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport { identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type { _UseErrorEach_F, UseErrorEach_F } from './error.types';\n\n/**\n * Runs error assertions for asynchronous test cases concurrently.\n */\nexport const useErrorAsyncEachCases: _UseErrorEach_F = (\n f,\n transform = identity as any,\n toError = () => undefined,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest.error(cases))(\n '%s',\n async (_, args, _error) => {\n const actual = async () => {\n const out = await f(...args);\n return transform(out);\n };\n const check = _error === undefined;\n const error = check ? toError(...args) : _error;\n\n await expect(actual).rejects.toThrowError(error);\n },\n );\n};\n\n/**\n * Higher-order function returning a test runner for asynchronous error assertions.\n *\n * @param f - Function to test.\n * @param transform - Optional transformer applied to the resolved return value.\n * @param toError - Optional function computing expected error message from arguments.\n *\n * @returns Function accepting error test cases to execute.\n */\nexport const useErrorAsyncEach: UseErrorEach_F = (\n f,\n transform,\n toError,\n) => {\n return (...cases) =>\n useErrorAsyncEachCases(f, transform, toError, ...cases);\n};\n"],"mappings":";;;;;;;AASA,MAAa,0BACX,GACA,YAAY,UACZ,gBAAgB,KAAA,GAChB,GAAG,UACA;CACH,KAAK,WAAW,KAAK,cAAc,MAAM,KAAK,CAAC,CAAC,CAC9C,MACA,OAAO,GAAG,MAAM,WAAW;EACzB,MAAM,SAAS,YAAY;GAEzB,OAAO,UAAU,MADC,EAAE,GAAG,IAAI,CACP;EACtB;EAEA,MAAM,QADQ,WAAW,KAAA,IACH,QAAQ,GAAG,IAAI,IAAI;EAEzC,MAAM,OAAO,MAAM,CAAC,CAAC,QAAQ,aAAa,KAAK;CACjD,CACF;AACF;;;;;;;;;;AAWA,MAAa,qBACX,GACA,WACA,YACG;CACH,QAAQ,GAAG,UACT,uBAAuB,GAAG,WAAW,SAAS,GAAG,KAAK;AAC1D"}
1
+ {"version":3,"file":"error.js","names":[],"sources":["../../../src/vitest-extended/each/error.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport { identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type { _UseErrorEach_F, UseErrorEach_F } from './error.types';\n\n/**\n * Runs error assertions for asynchronous test cases concurrently.\n */\nexport const useErrorAsyncEachCases: _UseErrorEach_F = (\n f,\n transform = identity as any,\n toError = () => undefined,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest.error(cases))('%s', async (_, args, _error) => {\n const actual = async () => {\n const out = await f(...args);\n return transform(out);\n };\n const check = _error === undefined;\n const error = check ? toError(...args) : _error;\n\n await expect(actual).rejects.toThrowError(error);\n });\n};\n\n/**\n * Higher-order function returning a test runner for asynchronous error assertions.\n *\n * @param f - Function to test.\n * @param transform - Optional transformer applied to the resolved return value.\n * @param toError - Optional function computing expected error message from arguments.\n *\n * @returns Function accepting error test cases to execute.\n */\nexport const useErrorAsyncEach: UseErrorEach_F = (f, transform, toError) => {\n return (...cases) => useErrorAsyncEachCases(f, transform, toError, ...cases);\n};\n"],"mappings":";;;;;;;AASA,MAAa,0BACX,GACA,YAAY,UACZ,gBAAgB,KAAA,GAChB,GAAG,UACA;CACH,KAAK,WAAW,KAAK,cAAc,MAAM,KAAK,CAAC,CAAC,CAAC,MAAM,OAAO,GAAG,MAAM,WAAW;EAChF,MAAM,SAAS,YAAY;GAEzB,OAAO,UAAU,MADC,EAAE,GAAG,IAAI,CACP;EACtB;EAEA,MAAM,QADQ,WAAW,KAAA,IACH,QAAQ,GAAG,IAAI,IAAI;EAEzC,MAAM,OAAO,MAAM,CAAC,CAAC,QAAQ,aAAa,KAAK;CACjD,CAAC;AACH;;;;;;;;;;AAWA,MAAa,qBAAqC,GAAG,WAAW,YAAY;CAC1E,QAAQ,GAAG,UAAU,uBAAuB,GAAG,WAAW,SAAS,GAAG,KAAK;AAC7E"}
@@ -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 * 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
+ {"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 = (func, transform = identity as any, ...cases) => {\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,gBAA4B,MAAM,YAAYA,iCAAAA,UAAiB,GAAG,UAAU;CAChF,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 +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 * 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
+ {"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 = (func, transform = identity as any, ...cases) => {\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,gBAA4B,MAAM,YAAY,UAAiB,GAAG,UAAU;CAChF,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 +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\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
+ {"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) => (index: number, ms?: number, times?: number) => [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":";;;AA+CA,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 +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\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
+ {"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) => (index: number, ms?: number, times?: number) => [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":";;AA+CA,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 +1 @@
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
+ {"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>) => f({ ...remainArgs, ...headArgs } as U);\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAgB,aACd,GACA,UACA;CACA,QAAQ,eAAiC,EAAE;EAAE,GAAG;EAAY,GAAG;CAAS,CAAM;AAChF"}
@@ -1 +1 @@
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
+ {"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>) => f({ ...remainArgs, ...headArgs } as U);\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAgB,aACd,GACA,UACA;CACA,QAAQ,eAAiC,EAAE;EAAE,GAAG;EAAY,GAAG;CAAS,CAAM;AAChF"}
@@ -1 +1 @@
1
- {"version":3,"file":"isFunction.cjs","names":[],"sources":["../../src/vitest-extended/isFunction.ts"],"sourcesContent":["/**\n * Determines whether the given value is a function.\n *\n * @param arg - The value to check.\n *\n * @returns `true` if `arg` is a function, otherwise `false`.\n */\nexport function isFunction(arg: any) {\n const isType = 'function' === typeof arg;\n const isInstance = arg instanceof Function;\n const isArrow =\n Object.prototype.toString.call(arg) === '[object Function]';\n\n return !!arg && (isType || isInstance || isArrow);\n}\n"],"mappings":";;;;;;;;;AAOA,SAAgB,WAAW,KAAU;CACnC,MAAM,SAAS,eAAe,OAAO;CACrC,MAAM,aAAa,eAAe;CAClC,MAAM,UACJ,OAAO,UAAU,SAAS,KAAK,GAAG,MAAM;CAE1C,OAAO,CAAC,CAAC,QAAQ,UAAU,cAAc;AAC3C"}
1
+ {"version":3,"file":"isFunction.cjs","names":[],"sources":["../../src/vitest-extended/isFunction.ts"],"sourcesContent":["/**\n * Determines whether the given value is a function.\n *\n * @param arg - The value to check.\n *\n * @returns `true` if `arg` is a function, otherwise `false`.\n */\nexport function isFunction(arg: any) {\n const isType = 'function' === typeof arg;\n const isInstance = arg instanceof Function;\n const isArrow = Object.prototype.toString.call(arg) === '[object Function]';\n\n return !!arg && (isType || isInstance || isArrow);\n}\n"],"mappings":";;;;;;;;;AAOA,SAAgB,WAAW,KAAU;CACnC,MAAM,SAAS,eAAe,OAAO;CACrC,MAAM,aAAa,eAAe;CAClC,MAAM,UAAU,OAAO,UAAU,SAAS,KAAK,GAAG,MAAM;CAExD,OAAO,CAAC,CAAC,QAAQ,UAAU,cAAc;AAC3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"isFunction.js","names":[],"sources":["../../src/vitest-extended/isFunction.ts"],"sourcesContent":["/**\n * Determines whether the given value is a function.\n *\n * @param arg - The value to check.\n *\n * @returns `true` if `arg` is a function, otherwise `false`.\n */\nexport function isFunction(arg: any) {\n const isType = 'function' === typeof arg;\n const isInstance = arg instanceof Function;\n const isArrow =\n Object.prototype.toString.call(arg) === '[object Function]';\n\n return !!arg && (isType || isInstance || isArrow);\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,WAAW,KAAU;CACnC,MAAM,SAAS,eAAe,OAAO;CACrC,MAAM,aAAa,eAAe;CAClC,MAAM,UACJ,OAAO,UAAU,SAAS,KAAK,GAAG,MAAM;CAE1C,OAAO,CAAC,CAAC,QAAQ,UAAU,cAAc;AAC3C"}
1
+ {"version":3,"file":"isFunction.js","names":[],"sources":["../../src/vitest-extended/isFunction.ts"],"sourcesContent":["/**\n * Determines whether the given value is a function.\n *\n * @param arg - The value to check.\n *\n * @returns `true` if `arg` is a function, otherwise `false`.\n */\nexport function isFunction(arg: any) {\n const isType = 'function' === typeof arg;\n const isInstance = arg instanceof Function;\n const isArrow = Object.prototype.toString.call(arg) === '[object Function]';\n\n return !!arg && (isType || isInstance || isArrow);\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,WAAW,KAAU;CACnC,MAAM,SAAS,eAAe,OAAO;CACrC,MAAM,aAAa,eAAe;CAClC,MAAM,UAAU,OAAO,UAAU,SAAS,KAAK,GAAG,MAAM;CAExD,OAAO,CAAC,CAAC,QAAQ,UAAU,cAAc;AAC3C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/dev-utils",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "A collection of utilities for Node.js development, including build tools, testing utilities, and configuration management.",
5
5
  "author": {
6
6
  "email": "bri_lvi@icloud.com",