Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DevTools: Profiler refactor incremental changes #23185

Merged
merged 9 commits into from
Jan 28, 2022
3,193 changes: 2,243 additions & 950 deletions packages/react-devtools-shared/src/__tests__/TimelineProfiler-test.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import hasOwnProperty from 'shared/hasOwnProperty';

const FILTERED_VERSION_STRING = '<filtered-version>';

// test() is part of Jest's serializer API
export function test(maybeProfile) {
if (
maybeProfile != null &&
typeof maybeProfile === 'object' &&
hasOwnProperty.call(maybeProfile, 'reactVersion') &&
maybeProfile.reactVersion !== FILTERED_VERSION_STRING
) {
return true;
}

return false;
}

// print() is part of Jest's serializer API
export function print(profile, serialize, indent) {
return serialize({
...profile,
reactVersion: FILTERED_VERSION_STRING,
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import hasOwnProperty from 'shared/hasOwnProperty';
import isArray from 'shared/isArray';

function formatLanes(laneArray) {
const lanes = laneArray.reduce((current, reduced) => current + reduced, 0);
return '0b' + lanes.toString(2).padStart(31, '0');
}

// test() is part of Jest's serializer API
export function test(maybeTimelineData) {
if (
maybeTimelineData != null &&
typeof maybeTimelineData === 'object' &&
hasOwnProperty.call(maybeTimelineData, 'lanes') &&
isArray(maybeTimelineData.lanes)
) {
return true;
}

return false;
}

// print() is part of Jest's serializer API
export function print(timelineData, serialize, indent) {
return serialize({
...timelineData,
lanes: formatLanes(timelineData.lanes),
});
}
Loading