Home / File/ dehydratedValueSerializer.js — react Source File

dehydratedValueSerializer.js — react Source File

Architecture documentation for dehydratedValueSerializer.js, a javascript file in the react codebase.

Entity Profile

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
 */

// `test` is part of Jest's serializer API
export function test(maybeDehydratedValue) {
  const {meta} = require('react-devtools-shared/src/hydration');

  const hasOwnProperty =
    Object.prototype.hasOwnProperty.bind(maybeDehydratedValue);
  return (
    maybeDehydratedValue !== null &&
    typeof maybeDehydratedValue === 'object' &&
    hasOwnProperty(meta.inspectable) &&
    maybeDehydratedValue[meta.inspected] !== true
  );
}

// print() is part of Jest's serializer API
export function print(dehydratedValue, serialize, indent) {
  const {meta} = require('react-devtools-shared/src/hydration');
  const indentation = Math.max(indent('.').indexOf('.') - 2, 0);
  const paddingLeft = ' '.repeat(indentation);
  return (
    'Dehydrated {\n' +
    paddingLeft +
    '  "preview_short": ' +
    dehydratedValue[meta.preview_short] +
    ',\n' +
    paddingLeft +
    '  "preview_long": ' +
    dehydratedValue[meta.preview_long] +
    ',\n' +
    paddingLeft +
    '}'
  );
}

Domain

Subdomains

Functions

Frequently Asked Questions

What does dehydratedValueSerializer.js do?
dehydratedValueSerializer.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in dehydratedValueSerializer.js?
dehydratedValueSerializer.js defines 2 function(s): print, test.
Where is dehydratedValueSerializer.js in the architecture?
dehydratedValueSerializer.js is located at packages/react-devtools-shared/src/__tests__/__serializers__/dehydratedValueSerializer.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/__tests__/__serializers__).

Analyze Your Own Codebase

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

Try Supermodel Free