pretty-format

  • Version 27.4.6
  • Published
  • 70 kB
  • 3 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

      Interfaces

      interface PrettyFormatOptions

      interface PrettyFormatOptions {}

        property callToJSON

        callToJSON?: boolean;

          property compareKeys

          compareKeys?: CompareKeys;

            property escapeRegex

            escapeRegex?: boolean;

              property escapeString

              escapeString?: boolean;

                property highlight

                highlight?: boolean;

                  property indent

                  indent?: number;

                    property maxDepth

                    maxDepth?: number;

                      property min

                      min?: boolean;

                        property plugins

                        plugins?: Plugins;

                          property printBasicPrototype

                          printBasicPrototype?: boolean;

                            property printFunctionName

                            printFunctionName?: boolean;

                              property theme

                              theme?: ThemeReceived;

                                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 CompareKeys

                                type CompareKeys = ((a: string, b: string) => number) | undefined;

                                  type Config

                                  type Config = {
                                  callToJSON: boolean;
                                  compareKeys: CompareKeys;
                                  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;
                                        compareKeys: CompareKeys;
                                        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 (3)

                                                      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>