-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: init delegates as explicitly undefined
- Loading branch information
Showing
3 changed files
with
21 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import { TimestampProvider } from "../types"; | ||
|
||
interface DateTimestampProvider extends TimestampProvider { | ||
delegate?: TimestampProvider; | ||
delegate: TimestampProvider | undefined; | ||
} | ||
|
||
export const dateTimestampProvider: DateTimestampProvider = { | ||
now() { return (this.delegate || Date).now(); } | ||
now() { | ||
// Use the variable rather than `this` so that the function can be called | ||
// without being bound to the provider. | ||
return (dateTimestampProvider.delegate || Date).now(); | ||
}, | ||
delegate: undefined | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import { TimestampProvider } from "../types"; | ||
|
||
interface PerformanceTimestampProvider extends TimestampProvider { | ||
delegate?: TimestampProvider; | ||
delegate: TimestampProvider | undefined; | ||
} | ||
|
||
export const performanceTimestampProvider: PerformanceTimestampProvider = { | ||
now() { return (this.delegate || performance).now(); } | ||
now() { | ||
// Use the variable rather than `this` so that the function can be called | ||
// without being bound to the provider. | ||
return (performanceTimestampProvider.delegate || performance).now(); | ||
}, | ||
delegate: undefined | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters