@ark/attest 0.10.0 → 0.10.2
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/out/assert/attest.d.ts +5 -1
- package/out/bench/bench.d.ts +6 -1
- package/out/bench/bench.js +4 -1
- package/package.json +5 -5
package/out/assert/attest.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { type SourcePosition } from "@ark/fs";
|
|
2
|
+
import type { ErrorMessage } from "@ark/util";
|
|
2
3
|
import type { Measure } from "../bench/measure.js";
|
|
3
4
|
import { type VersionedTypeAssertion } from "../cache/getCachedAssertions.js";
|
|
4
5
|
import { type AttestConfig } from "../config.js";
|
|
5
6
|
import { ChainableAssertions, type AssertionKind, type rootAssertions } from "./chainableAssertions.js";
|
|
6
7
|
export type AttestFn = {
|
|
7
|
-
<expected, actual extends expected = never>(...args:
|
|
8
|
+
<expected, actual extends expected = never>(...args: actual extends never ? [
|
|
9
|
+
ErrorMessage<"Type-only assertion requires two explicit genreic params, e.g. attest<expected, actual>">
|
|
10
|
+
] : []): void;
|
|
11
|
+
<expected>(actual: expected): rootAssertions<expected, AssertionKind>;
|
|
8
12
|
instantiations: (count?: Measure<"instantiations"> | undefined) => void;
|
|
9
13
|
};
|
|
10
14
|
export type AssertionContext = {
|
package/out/bench/bench.d.ts
CHANGED
|
@@ -4,7 +4,11 @@ import { type MarkMeasure, type Measure, type TimeUnit } from "./measure.js";
|
|
|
4
4
|
import { type BenchTypeAssertions } from "./type.js";
|
|
5
5
|
export type StatName = keyof typeof stats;
|
|
6
6
|
export type TimeAssertionName = StatName | "mark";
|
|
7
|
-
|
|
7
|
+
type BenchFn = <fn extends BenchableFunction>(name: string, fn: fn, options?: BenchOptions) => InitialBenchAssertions<fn>;
|
|
8
|
+
export interface Bench extends BenchFn {
|
|
9
|
+
baseline: <T>(baselineExpressions: () => T) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const bench: Bench;
|
|
8
12
|
export declare const stats: {
|
|
9
13
|
mean: (callTimes: number[]) => number;
|
|
10
14
|
median: (callTimes: number[]) => number;
|
|
@@ -56,3 +60,4 @@ export type BenchContext = {
|
|
|
56
60
|
export type BenchableFunction = () => unknown | Promise<unknown>;
|
|
57
61
|
export type InitialBenchAssertions<Fn extends BenchableFunction> = BenchAssertions<Fn> & BenchTypeAssertions;
|
|
58
62
|
export declare const getBenchCtx: (qualifiedPath: string[], isAsync?: boolean, options?: BenchOptions) => BenchContext;
|
|
63
|
+
export {};
|
package/out/bench/bench.js
CHANGED
|
@@ -8,7 +8,7 @@ import { call1K } from "./call1k.js";
|
|
|
8
8
|
import { createTimeComparison, createTimeMeasure } from "./measure.js";
|
|
9
9
|
import { createBenchTypeAssertion } from "./type.js";
|
|
10
10
|
let benchHasRun = false;
|
|
11
|
-
|
|
11
|
+
const benchFn = (name, fn, options) => {
|
|
12
12
|
const qualifiedPath = [...currentSuitePath, name];
|
|
13
13
|
console.log(`🏌️ ${qualifiedPath.join("/")}`);
|
|
14
14
|
const ctx = getBenchCtx(qualifiedPath, fn.constructor.name === "AsyncFunction", options);
|
|
@@ -28,6 +28,9 @@ export const bench = (name, fn, options = {}) => {
|
|
|
28
28
|
Object.assign(assertions, createBenchTypeAssertion(ctx));
|
|
29
29
|
return assertions;
|
|
30
30
|
};
|
|
31
|
+
export const bench = Object.assign(benchFn, {
|
|
32
|
+
baseline: () => { }
|
|
33
|
+
});
|
|
31
34
|
export const stats = {
|
|
32
35
|
mean: (callTimes) => {
|
|
33
36
|
const totalCallMs = callTimes.reduce((sum, duration) => sum + duration, 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ark/attest",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "David Blass",
|
|
6
6
|
"email": "david@arktype.io",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"@typescript/analyze-trace": "0.10.1",
|
|
30
30
|
"prettier": "3.3.3",
|
|
31
31
|
"@prettier/sync": "0.5.2",
|
|
32
|
-
"
|
|
33
|
-
"@ark/fs": "0.1.
|
|
34
|
-
"
|
|
32
|
+
"arktype": "2.0.0-beta.2",
|
|
33
|
+
"@ark/fs": "0.1.2",
|
|
34
|
+
"@ark/util": "0.1.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"typescript": "5.5.
|
|
37
|
+
"typescript": "5.5.4"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"typescript": "*"
|