mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37808 When passing entries of type "event" to `console.log` we only see the fields defined in the base `PerformanceEntry` class because it defines a `toJSON` method but the `PerformanceEventTiming` subclass doesn't. This implements the method in that class too to improve debuggability (while also making it more spec compliant). Changelog: [internal] Reviewed By: rshest Differential Revision: D46597764 fbshipit-source-id: ca6fba3fdbb74a4f767eebc647681e5b65ba65d8
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow strict
|
|
*/
|
|
|
|
export type HighResTimeStamp = number;
|
|
export type PerformanceEntryType = 'mark' | 'measure' | 'event';
|
|
|
|
export type PerformanceEntryJSON = {
|
|
name: string,
|
|
entryType: PerformanceEntryType,
|
|
startTime: HighResTimeStamp,
|
|
duration: HighResTimeStamp,
|
|
...
|
|
};
|
|
|
|
export const ALWAYS_LOGGED_ENTRY_TYPES: $ReadOnlyArray<PerformanceEntryType> = [
|
|
'mark',
|
|
'measure',
|
|
];
|
|
|
|
export class PerformanceEntry {
|
|
name: string;
|
|
entryType: PerformanceEntryType;
|
|
startTime: HighResTimeStamp;
|
|
duration: HighResTimeStamp;
|
|
|
|
constructor(init: {
|
|
name: string,
|
|
entryType: PerformanceEntryType,
|
|
startTime: HighResTimeStamp,
|
|
duration: HighResTimeStamp,
|
|
}) {
|
|
this.name = init.name;
|
|
this.entryType = init.entryType;
|
|
this.startTime = init.startTime;
|
|
this.duration = init.duration;
|
|
}
|
|
|
|
toJSON(): PerformanceEntryJSON {
|
|
return {
|
|
name: this.name,
|
|
entryType: this.entryType,
|
|
startTime: this.startTime,
|
|
duration: this.duration,
|
|
};
|
|
}
|
|
}
|