pretty-format

  • Version 27.2.5
  • Published
  • 69.3 kB
  • 4 dependencies
  • MIT license

Install

npm i pretty-format
yarn add pretty-format
pnpm add pretty-format

Overview

Stringify any JavaScript value.

Index

Variables

variable DEFAULT_OPTIONS

const DEFAULT_OPTIONS: Options;

    variable plugins

    const plugins: {
    AsymmetricMatcher: NewPlugin;
    ConvertAnsi: NewPlugin;
    DOMCollection: NewPlugin;
    DOMElement: NewPlugin;
    Immutable: NewPlugin;
    ReactElement: NewPlugin;
    ReactTestComponent: NewPlugin;
    };

      Functions

      function format

      format: (val: unknown, options?: OptionsReceived) => string;
      • Returns a presentation string of your val object

        Parameter val

        any potential JavaScript object

        Parameter options

        Custom settings

      Type Aliases

      type Colors

      type Colors = {
      comment: {
      close: string;
      open: string;
      };
      content: {
      close: string;
      open: string;
      };
      prop: {
      close: string;
      open: string;
      };
      tag: {
      close: string;
      open: string;
      };
      value: {
      close: string;
      open: string;
      };
      };
      • Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

        This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.

      type Config

      type Config = {
      callToJSON: boolean;
      colors: Colors;
      escapeRegex: boolean;
      escapeString: boolean;
      indent: string;
      maxDepth: number;
      min: boolean;
      plugins: Plugins;
      printBasicPrototype: boolean;
      printFunctionName: boolean;
      spacingInner: string;
      spacingOuter: string;
      };

        type NewPlugin

        type NewPlugin = {
        serialize: (
        val: any,
        config: Config,
        indentation: string,
        depth: number,
        refs: Refs,
        printer: Printer
        ) => string;
        test: Test;
        };

          type OldPlugin

          type OldPlugin = {
          print: (
          val: unknown,
          print: Print,
          indent: Indent,
          options: PluginOptions,
          colors: Colors
          ) => string;
          test: Test;
          };

            type Options

            type Options = {
            callToJSON: boolean;
            escapeRegex: boolean;
            escapeString: boolean;
            highlight: boolean;
            indent: number;
            maxDepth: number;
            min: boolean;
            plugins: Plugins;
            printBasicPrototype: boolean;
            printFunctionName: boolean;
            theme: Theme;
            };

              type OptionsReceived

              type OptionsReceived = PrettyFormatOptions;

                type Plugin

                type Plugin = NewPlugin | OldPlugin;

                  type Plugins

                  type Plugins = Array<Plugin>;

                    type Printer

                    type Printer = (
                    val: unknown,
                    config: Config,
                    indentation: string,
                    depth: number,
                    refs: Refs,
                    hasCalledToJSON?: boolean
                    ) => string;

                      type Refs

                      type Refs = Array<unknown>;

                        type Theme

                        type Theme = {
                        comment: string;
                        content: string;
                        prop: string;
                        tag: string;
                        value: string;
                        };

                          Package Files (2)

                          Dependencies (4)

                          Dev Dependencies (8)

                          Peer Dependencies (0)

                          No peer dependencies.

                          Badge

                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/pretty-format.

                          • Markdown
                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/pretty-format)
                          • HTML
                            <a href="https://www.jsdocs.io/package/pretty-format"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>