forked from tutao/tutanota
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolyfill.ts
40 lines (33 loc) · 794 Bytes
/
polyfill.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import "systemjs"
const globalContext = typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : self
const noOp = function () {
}
if (typeof performance === "undefined") {
// @ts-ignore
self.performance = {
// @ts-ignore
offset: Date.now(),
now: function now() {
// @ts-ignore
return Date.now() - this.offset
},
}
}
if (typeof performance.mark !== "function") {
// @ts-ignore
performance.mark = noOp
}
if (typeof performance.measure !== "function") {
// @ts-ignore
performance.measure = noOp
}
// We need BigInt stub for cborg
if (typeof BigInt === "undefined") {
console.log("No BigInt support in browser, stubbing...")
function BigInt(arg: any) {
return arg
}
BigInt.polyfilled = true
// @ts-ignore
globalContext.BigInt = BigInt
}