/
ashipov
/
react
Обзор
Документация
Войти
/
ashipov
/
react
Код
Запросы
0
Задачи 2.0
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
packages/react-devtools-timeline/src/import-worker/importFile.js
46 строк
1 KB
Jan Kassens
ESLint upgrade to use hermes-eslint (#25915)
20 дек 2022, 22:27
Не верифицирован
20 дек 2022, 22:27
2b1fb91
Код
Авторство
О чём код?
/** * 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. * * @flow */ import 'regenerator-runtime/runtime'; import type {TimelineEvent} from '@elg/speedscope'; import type {ImportWorkerOutputData} from './index'; import preprocessData from './preprocessData'; import {readInputData} from './readInputData'; import InvalidProfileError from './InvalidProfileError'; export async function importFile(file: File): Promise<ImportWorkerOutputData> { try { const readFile = await readInputData(file); const events: TimelineEvent[] = JSON.parse(readFile); if (events.length === 0) { throw new InvalidProfileError('No profiling data found in file.'); } const processedData = await preprocessData(events); return { status: 'SUCCESS', processedData, }; } catch (error) { if (error instanceof InvalidProfileError) { return { status: 'INVALID_PROFILE_ERROR', error, }; } else { return { status: 'UNEXPECTED_ERROR', error, }; } } }