tinybench
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "tinybench", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A benchmarking library that supports high-resolution timers & returns statistically significant results.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -1,10 +0,19 @@ | ||
// Type definitions for Benchmark v2.1.4 | ||
// Project: https://benchmarkjs.com | ||
// Type definitions for tinybench | ||
// based on @types/benchmark | ||
// Definitions by: Asana <https://asana.com> | ||
// Charlie Fish <https://github.com/fishcharlie> | ||
// Blair Zajac <https://github.com/blair> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
type AnyObject = { [key: string | number | symbol]: any; }; | ||
type EventHandler<T> = (this: T, event: Benchmark.Event) => void; | ||
type EventType = | ||
'abort' | | ||
'complete' | | ||
'cycle' | | ||
'error' | | ||
'reset' | | ||
'start'; | ||
type EventTypeMixed = string; | ||
declare class Benchmark { | ||
@@ -106,3 +115,3 @@ | ||
*/ | ||
static runInContext(context: AnyObject): Function; | ||
static runInContext(context: AnyObject): Benchmark; | ||
@@ -216,5 +225,5 @@ static each(obj: AnyObject | any[], callback: Function, thisArg?: any): void; | ||
*/ | ||
constructor(name: string, fn: Function | (ThisBenchmarkFunction) | string, options?: Benchmark.Options); | ||
constructor(name: string, fn: ((this: Benchmark) => void) | string, options?: Benchmark.Options); | ||
constructor(name: string, options?: Benchmark.Options); | ||
constructor(fn: Function | (ThisBenchmarkFunction) | string, options?: Benchmark.Options); | ||
constructor(fn: ((this: Benchmark) => void) | string, options?: Benchmark.Options); | ||
constructor(options: Benchmark.Options); | ||
@@ -342,3 +351,3 @@ | ||
*/ | ||
setup: ThisBenchmarkFunction | string; | ||
setup: ((this: Benchmark) => void) | string; | ||
@@ -350,3 +359,3 @@ /** | ||
*/ | ||
teardown: ThisBenchmarkFunction | string; | ||
teardown: ((this: Benchmark) => void) | string; | ||
@@ -411,3 +420,3 @@ /** | ||
*/ | ||
listeners(type: string): Function[]; | ||
listeners(type: string): EventHandler<Benchmark>[]; | ||
@@ -439,4 +448,4 @@ /** | ||
*/ | ||
off(type?: string, fn?: Function): Benchmark; | ||
off(types: string[]): Benchmark; | ||
off(type?: EventTypeMixed, fn?: EventHandler<Benchmark>): Benchmark; | ||
off(types: EventType[]): Benchmark; | ||
@@ -457,4 +466,4 @@ /** | ||
*/ | ||
on(type?: string, fn?: Function): Benchmark; | ||
on(types: string[]): Benchmark; | ||
on(type?: EventTypeMixed, fn?: EventHandler<Benchmark>): Benchmark; | ||
on(types: EventType[]): Benchmark; | ||
@@ -493,4 +502,2 @@ /** | ||
type ThisBenchmarkFunction = (this: Benchmark) => void; | ||
declare namespace Benchmark { | ||
@@ -576,3 +583,3 @@ export interface Options { | ||
*/ | ||
onAbort?: Function | undefined; | ||
onAbort?: EventHandler<Benchmark> | undefined; | ||
@@ -584,3 +591,3 @@ /** | ||
*/ | ||
onComplete?: Function | undefined; | ||
onComplete?: EventHandler<Benchmark> | undefined; | ||
@@ -592,3 +599,3 @@ /** | ||
*/ | ||
onCycle?: Function | undefined; | ||
onCycle?: EventHandler<Benchmark> | undefined; | ||
@@ -600,3 +607,3 @@ /** | ||
*/ | ||
onError?: Function | undefined; | ||
onError?: EventHandler<Benchmark> | undefined; | ||
@@ -608,3 +615,3 @@ /** | ||
*/ | ||
onReset?: Function | undefined; | ||
onReset?: EventHandler<Benchmark> | undefined; | ||
@@ -616,7 +623,7 @@ /** | ||
*/ | ||
onStart?: Function | undefined; | ||
onStart?: EventHandler<Benchmark> | undefined; | ||
setup?: ThisBenchmarkFunction | string | undefined; | ||
teardown?: ThisBenchmarkFunction | string | undefined; | ||
fn?: Function | string | undefined; | ||
setup?: ((this: Benchmark) => void) | string | undefined; | ||
teardown?: ((this: Benchmark) => void) | string | undefined; | ||
fn?: ((deferred: Deferred) => void) | (() => void) | string | undefined; | ||
queued?: boolean | undefined; | ||
@@ -881,3 +888,3 @@ } | ||
*/ | ||
constructor(type: string | Object); | ||
constructor(type: EventType | Object); | ||
@@ -931,3 +938,3 @@ /** | ||
*/ | ||
type: string; | ||
type: EventType; | ||
} | ||
@@ -1060,4 +1067,14 @@ | ||
*/ | ||
add(name: string, fn: Function | string, options?: Options): Suite; | ||
add(fn: Function | string, options?: Options): Suite; | ||
add(name: string, fn: ((this: Suite, deferred: Deferred) => void), options: Options): Suite; | ||
add(name: string, fn: ((this: Suite) => void), options: Options): Suite; | ||
add(name: string, fn: string, options: Options): Suite; | ||
add(name: string, fn: ((this: Suite, deferred: Deferred) => void)): Suite; | ||
add(name: string, fn: ((this: Suite) => void)): Suite; | ||
add(name: string, fn: string): Suite; | ||
add(fn: ((this: Suite, deferred: Deferred) => void), options: Options): Suite; | ||
add(fn: ((this: Suite) => void), options: Options): Suite; | ||
add(fn: string, options: Options): Suite; | ||
add(fn: ((this: Suite, deferred: Deferred) => void)): Suite; | ||
add(fn: ((this: Suite) => void)): Suite; | ||
add(fn: string): Suite; | ||
add(name: string, options?: Options): Suite; | ||
@@ -1101,3 +1118,3 @@ add(options: Options): Suite; | ||
*/ | ||
listeners(type: string): Function[]; | ||
listeners(type: string): EventHandler<Suite>[]; | ||
@@ -1129,4 +1146,4 @@ /** | ||
*/ | ||
off(type?: string, callback?: Function): Suite; | ||
off(types: string[]): Suite; | ||
off(type?: EventTypeMixed, callback?: EventHandler<Suite>): Suite; | ||
off(types: EventType[]): Suite; | ||
@@ -1147,4 +1164,4 @@ /** | ||
*/ | ||
on(type?: string, fn?: Function): Suite; | ||
on(types: string[]): Suite; | ||
on(type?: EventTypeMixed, fn?: EventHandler<Suite>): Suite; | ||
on(types: EventType[]): Suite; | ||
push(benchmark: Benchmark): number; | ||
@@ -1180,3 +1197,3 @@ | ||
*/ | ||
reverse(): any[]; | ||
reverse(): Benchmark[]; | ||
@@ -1193,3 +1210,3 @@ /** | ||
*/ | ||
sort(compareFn: (a: any, b: any) => number): any[]; | ||
sort(compareFn: (a: Benchmark, b: Benchmark) => number): Benchmark[]; | ||
@@ -1203,12 +1220,13 @@ /** | ||
*/ | ||
splice(start: number, deleteCount?: number, items?: Suite): Suite[]; | ||
splice(start: number, deleteCount?: number, items?: Benchmark): Benchmark[]; | ||
unshift(benchmark: Benchmark): number; | ||
each(callback: Function): Suite; | ||
forEach(callback: Function): Suite; | ||
indexOf(value: any): number; | ||
map(callback: Function | string): any[]; | ||
reduce<T>(callback: Function, accumulator: T): T; | ||
each(callbackfn: (value: Benchmark, index: number, array: Suite) => void, thisArg?: Suite): Suite; | ||
forEach(callbackfn: (value: Benchmark, index: number, array: Suite) => void, thisArg?: Suite): Suite; | ||
indexOf(searchElement: Benchmark, fromIndex?: number): number; | ||
map(callbackfn: (value: Benchmark, index: number, array: Suite) => number, thisArg?: any): any[]; | ||
map(value: string): Benchmark[] | ||
reduce(callbackfn: (previousValue: Benchmark, currentValue: Benchmark, currentIndex: number, array: Benchmark[]) => Benchmark, initialValue?: Benchmark): Benchmark; | ||
pop(): Function; | ||
pop(): Benchmark; | ||
shift(): Benchmark; | ||
@@ -1215,0 +1233,0 @@ slice(start: number, end: number): any[]; |
108082
3053