0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00

perf_hooks: add missing type argument to getEntriesByName

Fixes: https://github.com/nodejs/node/issues/54766
PR-URL: https://github.com/nodejs/node/pull/54767
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Luke Taher 2024-09-24 20:39:51 +01:00 committed by GitHub
parent b8493a5789
commit 04750afb1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -97,13 +97,16 @@ class Performance extends EventTarget {
return filterBufferMapByNameAndType();
}
getEntriesByName(name) {
getEntriesByName(name, type = undefined) {
validateInternalField(this, kPerformanceBrand, 'Performance');
if (arguments.length === 0) {
throw new ERR_MISSING_ARGS('name');
}
name = `${name}`;
return filterBufferMapByNameAndType(name, undefined);
if (type !== undefined) {
type = `${type}`;
}
return filterBufferMapByNameAndType(name, type);
}
getEntriesByType(type) {

View File

@ -33,6 +33,12 @@ await setTimeout(50);
performance.measure('a', 'one');
const entriesByName = performance.getEntriesByName('a');
assert.deepStrictEqual(entriesByName.map((x) => x.entryType), ['measure', 'mark', 'measure', 'mark']);
const marksByName = performance.getEntriesByName('a', 'mark');
assert.deepStrictEqual(marksByName.map((x) => x.entryType), ['mark', 'mark']);
const measuresByName = performance.getEntriesByName('a', 'measure');
assert.deepStrictEqual(measuresByName.map((x) => x.entryType), ['measure', 'measure']);
const invalidTypeEntriesByName = performance.getEntriesByName('a', null);
assert.strictEqual(invalidTypeEntriesByName.length, 0);
// getEntriesBy[Name|Type](undefined)
performance.mark(undefined);