diff options
-rw-r--r-- | cli/tests/unit_node/perf_hooks_test.ts | 10 | ||||
-rw-r--r-- | ext/node/polyfills/perf_hooks.ts | 5 |
2 files changed, 14 insertions, 1 deletions
diff --git a/cli/tests/unit_node/perf_hooks_test.ts b/cli/tests/unit_node/perf_hooks_test.ts index 2249e62f8..d1ab8c12c 100644 --- a/cli/tests/unit_node/perf_hooks_test.ts +++ b/cli/tests/unit_node/perf_hooks_test.ts @@ -13,12 +13,22 @@ Deno.test({ assertEquals(perfHooks.performance.clearMarks, performance.clearMarks); assertEquals(perfHooks.performance.mark, performance.mark); 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 assertEquals(perfHooks.performance.toJSON, performance.toJSON); perfHooks.performance.measure("test"); perfHooks.performance.mark("test"); perfHooks.performance.clearMarks("test"); perfHooks.performance.now(); + assertEquals(perfHooks.performance.getEntriesByName("event", "mark"), []); + assertEquals(perfHooks.performance.getEntriesByType("mark"), []); // @ts-ignore toJSON is not in Performance interface perfHooks.performance.toJSON(); }, diff --git a/ext/node/polyfills/perf_hooks.ts b/ext/node/polyfills/perf_hooks.ts index 64c2c3e06..5be2da991 100644 --- a/ext/node/polyfills/perf_hooks.ts +++ b/ext/node/polyfills/perf_hooks.ts @@ -16,7 +16,7 @@ const constants = {}; const performance: & Omit< Performance, - "clearMeasures" | "getEntries" | "getEntriesByName" | "getEntriesByType" + "clearMeasures" | "getEntries" > & { // deno-lint-ignore no-explicit-any @@ -58,6 +58,9 @@ const performance: // deno-lint-ignore no-explicit-any return (shimPerformance as any).timeOrigin; }, + getEntriesByName: (name, type) => + shimPerformance.getEntriesByName(name, type), + getEntriesByType: (type) => shimPerformance.getEntriesByType(type), markResourceTiming: () => {}, // @ts-ignore waiting on update in `deno`, but currently this is // a circular dependency |