| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ const { | |||
| 9 | 9 | const { | |
| 10 | 10 | codes: { | |
| 11 | 11 | ERR_ILLEGAL_CONSTRUCTOR, | |
| 12 | + ERR_MISSING_ARGS | ||
| 12 | 13 | } | |
| 13 | 14 | } = require('internal/errors'); | |
| 14 | 15 | ||
@@ -86,16 +87,18 @@ function getEntries() { | |||
| 86 | 87 | } | |
| 87 | 88 | ||
| 88 | 89 | function getEntriesByName(name) { | |
| 89 | - if (name !== undefined) { | ||
| 90 | - name = `${name}`; | ||
| 90 | + if (arguments.length === 0) { | ||
| 91 | + throw new ERR_MISSING_ARGS('name'); | ||
| 91 | 92 | } | |
| 93 | + name = `${name}`; | ||
| 92 | 94 | return filterBufferMapByNameAndType(name, undefined); | |
| 93 | 95 | } | |
| 94 | 96 | ||
| 95 | 97 | function getEntriesByType(type) { | |
| 96 | - if (type !== undefined) { | ||
| 97 | - type = `${type}`; | ||
| 98 | + if (arguments.length === 0) { | ||
| 99 | + throw new ERR_MISSING_ARGS('type'); | ||
| 98 | 100 | } | |
| 101 | + type = `${type}`; | ||
| 99 | 102 | return filterBufferMapByNameAndType(undefined, type); | |
| 100 | 103 | } | |
| 101 | 104 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,3 +33,18 @@ await setTimeout(50); | |||
| 33 | 33 | performance.measure('a', 'one'); | |
| 34 | 34 | const entriesByName = performance.getEntriesByName('a'); | |
| 35 | 35 | assert.deepStrictEqual(entriesByName.map((x) => x.entryType), ['measure', 'mark', 'measure', 'mark']); | |
| 36 | + | ||
| 37 | + // getEntriesBy[Name|Type](undefined) | ||
| 38 | + performance.mark(undefined); | ||
| 39 | + assert.strictEqual(performance.getEntriesByName(undefined).length, 1); | ||
| 40 | + assert.strictEqual(performance.getEntriesByType(undefined).length, 0); | ||
| 41 | + assert.throws(() => performance.getEntriesByName(), { | ||
| 42 | + name: 'TypeError', | ||
| 43 | + message: 'The "name" argument must be specified', | ||
| 44 | + code: 'ERR_MISSING_ARGS' | ||
| 45 | + }); | ||
| 46 | + assert.throws(() => performance.getEntriesByType(), { | ||
| 47 | + name: 'TypeError', | ||
| 48 | + message: 'The "type" argument must be specified', | ||
| 49 | + code: 'ERR_MISSING_ARGS' | ||
| 50 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments