mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(ext/node): add APIs perf_hook.performance (#21192)
Required for Next.js.
This commit is contained in:
parent
886652156e
commit
cf6673b23d
2 changed files with 14 additions and 1 deletions
|
@ -13,12 +13,22 @@ Deno.test({
|
||||||
assertEquals(perfHooks.performance.clearMarks, performance.clearMarks);
|
assertEquals(perfHooks.performance.clearMarks, performance.clearMarks);
|
||||||
assertEquals(perfHooks.performance.mark, performance.mark);
|
assertEquals(perfHooks.performance.mark, performance.mark);
|
||||||
assertEquals(perfHooks.performance.now, performance.now);
|
assertEquals(perfHooks.performance.now, performance.now);
|
||||||
|
assertEquals(
|
||||||
|
perfHooks.performance.getEntriesByName,
|
||||||
|
performance.getEntriesByName,
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
perfHooks.performance.getEntriesByType,
|
||||||
|
performance.getEntriesByType,
|
||||||
|
);
|
||||||
// @ts-ignore toJSON is not in Performance interface
|
// @ts-ignore toJSON is not in Performance interface
|
||||||
assertEquals(perfHooks.performance.toJSON, performance.toJSON);
|
assertEquals(perfHooks.performance.toJSON, performance.toJSON);
|
||||||
perfHooks.performance.measure("test");
|
perfHooks.performance.measure("test");
|
||||||
perfHooks.performance.mark("test");
|
perfHooks.performance.mark("test");
|
||||||
perfHooks.performance.clearMarks("test");
|
perfHooks.performance.clearMarks("test");
|
||||||
perfHooks.performance.now();
|
perfHooks.performance.now();
|
||||||
|
assertEquals(perfHooks.performance.getEntriesByName("event", "mark"), []);
|
||||||
|
assertEquals(perfHooks.performance.getEntriesByType("mark"), []);
|
||||||
// @ts-ignore toJSON is not in Performance interface
|
// @ts-ignore toJSON is not in Performance interface
|
||||||
perfHooks.performance.toJSON();
|
perfHooks.performance.toJSON();
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,7 +16,7 @@ const constants = {};
|
||||||
const performance:
|
const performance:
|
||||||
& Omit<
|
& Omit<
|
||||||
Performance,
|
Performance,
|
||||||
"clearMeasures" | "getEntries" | "getEntriesByName" | "getEntriesByType"
|
"clearMeasures" | "getEntries"
|
||||||
>
|
>
|
||||||
& {
|
& {
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
|
@ -58,6 +58,9 @@ const performance:
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
return (shimPerformance as any).timeOrigin;
|
return (shimPerformance as any).timeOrigin;
|
||||||
},
|
},
|
||||||
|
getEntriesByName: (name, type) =>
|
||||||
|
shimPerformance.getEntriesByName(name, type),
|
||||||
|
getEntriesByType: (type) => shimPerformance.getEntriesByType(type),
|
||||||
markResourceTiming: () => {},
|
markResourceTiming: () => {},
|
||||||
// @ts-ignore waiting on update in `deno`, but currently this is
|
// @ts-ignore waiting on update in `deno`, but currently this is
|
||||||
// a circular dependency
|
// a circular dependency
|
||||||
|
|
Loading…
Add table
Reference in a new issue