Reorganize file structure
This commit is contained in:
1 parent
f6888b8872
commit
b8a8d37e36
24 files changed
+3
-2
No files matched your search
@@ -0,0 +1,7 @@
|
||||
import { monotonicTime } from "./performancePolyfill";
|
||||
|
||||
describe("Check performance.now polyfill", () => {
|
||||
it("monotonicTime should return number", () => {
|
||||
expect(typeof monotonicTime()).toEqual("number");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
function makeMonotonicTime(): () => number {
|
||||
if (typeof performance !== "undefined" && performance) {
|
||||
let nowFun = performance.now ||
|
||||
performance.webkitNow ||
|
||||
performance.mozNow ||
|
||||
performance.oNow ||
|
||||
performance.msNow;
|
||||
|
||||
if (nowFun) {
|
||||
return nowFun.bind(performance);
|
||||
} else {
|
||||
return Date.now;
|
||||
}
|
||||
} else {
|
||||
return Date.now;
|
||||
}
|
||||
}
|
||||
|
||||
export const monotonicTime = makeMonotonicTime();
|
||||
Reference in new issue
Block a user