Home / File/ readInputData.js — react Source File

readInputData.js — react Source File

Architecture documentation for readInputData.js, a javascript file in the react codebase. 3 imports, 1 dependents.

File javascript BabelCompiler 3 imports 1 dependents

Entity Profile

Dependency Diagram

graph LR
  3a5f9bc5_a9d9_a302_c2cf_3bd912ebac45["readInputData.js"]
  13abdd7e_19d6_ddf6_8ae1_57dfb3f3b72f["InvalidProfileError.js"]
  3a5f9bc5_a9d9_a302_c2cf_3bd912ebac45 --> 13abdd7e_19d6_ddf6_8ae1_57dfb3f3b72f
  faa5ed90_bf45_aadf_762b_9cbd1a91aa65["InvalidProfileError"]
  3a5f9bc5_a9d9_a302_c2cf_3bd912ebac45 --> faa5ed90_bf45_aadf_762b_9cbd1a91aa65
  5146604b_db84_cd28_8c75_6114717bac64["nullthrows"]
  3a5f9bc5_a9d9_a302_c2cf_3bd912ebac45 --> 5146604b_db84_cd28_8c75_6114717bac64
  7413ab6d_5a4b_26b9_6ff5_21bf96ba027f["importFile.js"]
  7413ab6d_5a4b_26b9_6ff5_21bf96ba027f --> 3a5f9bc5_a9d9_a302_c2cf_3bd912ebac45
  style 3a5f9bc5_a9d9_a302_c2cf_3bd912ebac45 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * 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 nullthrows from 'nullthrows';
import InvalidProfileError from './InvalidProfileError';

export const readInputData = (file: File): Promise<string> => {
  if (!file.name.endsWith('.json')) {
    throw new InvalidProfileError(
      'Invalid file type. Only JSON performance profiles are supported',
    );
  }

  const fileReader = new FileReader();

  return new Promise((resolve, reject) => {
    fileReader.onload = () => {
      const result = nullthrows(fileReader.result);
      if (typeof result === 'string') {
        resolve(result);
      }
      reject(new InvalidProfileError('Input file was not read as a string'));
    };

    fileReader.onerror = () => reject(fileReader.error);

    fileReader.readAsText(file);
  });
};

Domain

Frequently Asked Questions

What does readInputData.js do?
readInputData.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does readInputData.js depend on?
readInputData.js imports 3 module(s): InvalidProfileError, InvalidProfileError.js, nullthrows.
What files import readInputData.js?
readInputData.js is imported by 1 file(s): importFile.js.
Where is readInputData.js in the architecture?
readInputData.js is located at packages/react-devtools-timeline/src/import-worker/readInputData.js (domain: BabelCompiler, directory: packages/react-devtools-timeline/src/import-worker).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free