GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: enforce optional signature (#633) · tinylibs/tinybench@b54b73b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • bench.ts
    • event.ts
    • task.ts
    • utils.ts
  • test
    • utils-default-convert-task-result-for-console-table.test.ts
  • tsconfig.json
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/bench.ts‎

Copy file name to clipboardExpand all lines: src/bench.ts
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class Bench extends EventTarget implements BenchLike {
146146
* Otherwise calibrated once at construction time via
147147
* {@link calibrateTimerOverhead}.
148148
*/
149-
readonly timerOverhead: number | undefined
149+
readonly timerOverhead?: number
150150

151151
/**
152152
* A timestamp provider and its related functions.
@@ -221,16 +221,21 @@ export class Bench extends EventTarget implements BenchLike {
221221
this.setup = restOptions.setup ?? emptyFunction
222222
this.teardown = restOptions.teardown ?? emptyFunction
223223
this.throws = restOptions.throws ?? false
224-
this.signal = restOptions.signal
224+
if (restOptions.signal != null) {
225+
this.signal = restOptions.signal
226+
}
225227
this.retainSamples = restOptions.retainSamples === true
226228
this.subtractTimerOverhead = restOptions.subtractTimerOverhead === true
227229
assert(
228230
!(this.subtractTimerOverhead && this.concurrency === 'task'),
229231
subtractTimerOverheadConcurrencyError
230232
)
231-
this.timerOverhead = this.subtractTimerOverhead
233+
const timerOverhead = this.subtractTimerOverhead
232234
? calibrateTimerOverhead(this.timestampProvider)
233235
: undefined
236+
if (timerOverhead != null) {
237+
this.timerOverhead = timerOverhead
238+
}
234239

235240
if (this.signal) {
236241
this.signal.addEventListener(
Collapse file

‎src/event.ts‎

Copy file name to clipboardExpand all lines: src/event.ts
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ class BenchEvent<
6969
errorOrReason?: Error | TimerSaturationReason
7070
) {
7171
super(type)
72-
this.#task = task
72+
if (task != null) {
73+
this.#task = task
74+
}
7375
if (typeof errorOrReason === 'string') {
7476
this.#reason = errorOrReason
75-
} else {
77+
} else if (errorOrReason != null) {
7678
this.#error = errorOrReason
7779
}
7880
}
Collapse file

‎src/task.ts‎

Copy file name to clipboardExpand all lines: src/task.ts
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,9 @@ export class Task extends EventTarget {
622622
latencySamples,
623623
overriddenIndices,
624624
}: {
625-
error?: Error
626-
latencySamples?: number[]
627-
overriddenIndices?: Set<number>
625+
error: Error | undefined
626+
latencySamples: number[] | undefined
627+
overriddenIndices: Set<number> | undefined
628628
}): void {
629629
if (isValidSamples(latencySamples)) {
630630
this.#runs = latencySamples.length
Collapse file

‎src/utils.ts‎

Copy file name to clipboardExpand all lines: src/utils.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ interface WithConcurrencyOptions<R> {
774774
/**
775775
* An optional AbortSignal to cancel the execution.
776776
*/
777-
signal?: AbortSignal
777+
signal?: AbortSignal | undefined
778778
/**
779779
* The maximum amount of time to run the executions in milliseconds. If 0,
780780
* runs until iterations are completed.
Collapse file

‎test/utils-default-convert-task-result-for-console-table.test.ts‎

Copy file name to clipboardExpand all lines: test/utils-default-convert-task-result-for-console-table.test.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ test('defaultConvertTaskResultForConsoleTable - errored - with stack', () => {
170170

171171
test('defaultConvertTaskResultForConsoleTable - errored - without stack', () => {
172172
const error = new Error('Sample error')
173-
error.stack = undefined
173+
delete error.stack
174174
expect(
175175
defaultConvertTaskResultForConsoleTable({
176176
name: 'Sample Task',
Collapse file

‎tsconfig.json‎

Copy file name to clipboardExpand all lines: tsconfig.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"erasableSyntaxOnly": true,
1212
"noImplicitOverride": true,
1313
"noImplicitReturns": true,
14+
"exactOptionalPropertyTypes": true,
1415
"noImplicitThis": true,
1516
"noUncheckedIndexedAccess": true,
1617
"noUnusedLocals": true,

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.