Skip to content

Commit c5adba7

Browse files
committed
feat(performance): update to the performance API
related pr: aurelia/pal-nodejs#30
1 parent fc3d10a commit c5adba7

File tree

1 file changed

+59
-6
lines changed

1 file changed

+59
-6
lines changed

src/index.js

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function AggregateError(message: string, innerError?: Error, skipIfAlread
1515

1616
message += `${separator}Inner Error:\n`;
1717

18-
if (typeof(innerError) === 'string' ) {
18+
if (typeof (innerError) === 'string') {
1919
message += `Message: ${innerError}`;
2020
} else {
2121
if (innerError.message) {
@@ -78,6 +78,59 @@ interface Performance {
7878
* @return The timestamp, measured in milliseconds, accurate to one thousandth of a millisecond.
7979
*/
8080
now(): number;
81+
82+
/**
83+
* Removes the given mark from the browser's performance entry buffer.
84+
*
85+
* @param {string} [markName] A DOMString representing the name of the timestamp. If this argument is omitted, all performance entries with an entry type of "mark" will be removed.
86+
* @memberof IPerformance
87+
*/
88+
clearMarks(markName?: string): void;
89+
90+
/**
91+
* Removes the given measure from the browser's performance entry buffer.
92+
*
93+
* @param {string} [measureName] A DOMString representing the name of the timestamp. If this argument is omitted, all performance entries with an entry type of "measure" will be removed.
94+
* @memberof IPerformance
95+
*/
96+
clearMeasures(measureName?: string): void;
97+
98+
/**
99+
* Returns a list of PerformanceEntry objects based on the given name and entry type.
100+
*
101+
* @param {string} name The name of the entry to retrieve
102+
* @param {string} [entryType] The type of entry to retrieve such as "mark". The valid entry types are listed in PerformanceEntry.entryType.
103+
* @returns {*}
104+
* @memberof IPerformance
105+
*/
106+
getEntriesByName(name: string, entryType?: string): any;
107+
108+
/**
109+
* Returns a list of PerformanceEntry objects of the given entry type.
110+
*
111+
* @param {string} entryType The type of entry to retrieve such as "mark". The valid entry types are listed in PerformanceEntry.entryType.
112+
* @returns {*}
113+
* @memberof IPerformance
114+
*/
115+
getEntriesByType(entryType: string): any;
116+
117+
/**
118+
* Creates a timestamp in the browser's performance entry buffer with the given name.
119+
*
120+
* @param {string} markName a DOMString representing the name of the mark
121+
* @memberof IPerformance
122+
*/
123+
mark(markName: string): void;
124+
125+
/**
126+
* Creates a named timestamp in the browser's performance entry buffer between two specified marks (known as the start mark and end mark, respectively).
127+
*
128+
* @param {string} measureName a DOMString representing the name of the measure.
129+
* @param {string} [startMarkName] A DOMString representing the name of the measure's starting mark. May also be the name of a PerformanceTiming property.
130+
* @param {string} [endMarkName] A DOMString representing the name of the measure's ending mark. May also be the name of a PerformanceTiming property.
131+
* @memberof IPerformance
132+
*/
133+
measure(measureName: string, startMarkName?: string, endMarkName?: string): void;
81134
}
82135

83136
/**
@@ -170,14 +223,14 @@ interface ModuleNameOptions {
170223
* The singleton instance of the Platform API.
171224
*/
172225
export const PLATFORM: Platform = {
173-
noop() {},
174-
eachModule() {},
226+
noop() { },
227+
eachModule() { },
175228
moduleName(moduleName) {
176229
return moduleName;
177230
}
178231
};
179232

180-
PLATFORM.global = (function() {
233+
PLATFORM.global = (function () {
181234
// Workers don’t have `window`, only `self`
182235
if (typeof self !== 'undefined') {
183236
return self;
@@ -327,7 +380,7 @@ interface Dom {
327380
* @param newNode The node to append.
328381
* @param parentNode The node to append to, otherwise the document.body.
329382
*/
330-
appendNode(newNode: Node, parentNode?:Node): void;
383+
appendNode(newNode: Node, parentNode?: Node): void;
331384
/**
332385
* Replaces a node in the parent with a new node.
333386
* @param newNode The node to replace the old node with.
@@ -367,7 +420,7 @@ export function initializePAL(callback: (platform: Platform, feature: Feature, d
367420
}
368421
isInitialized = true;
369422
if (typeof Object.getPropertyDescriptor !== 'function') {
370-
Object.getPropertyDescriptor = function(subject, name) {
423+
Object.getPropertyDescriptor = function (subject, name) {
371424
let pd = Object.getOwnPropertyDescriptor(subject, name);
372425
let proto = Object.getPrototypeOf(subject);
373426
while (typeof pd === 'undefined' && proto !== null) {

0 commit comments

Comments
 (0)