pretty-format

  • Version 28.1.3
  • Published
  • 64.1 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

      Interfaces

      interface Options

      interface Options extends Omit<RequiredOptions, 'compareKeys' | 'theme'> {}

        property compareKeys

        compareKeys: CompareKeys;

          property theme

          theme: Required<RequiredOptions['theme']>;

            interface PrettyFormatOptions

            interface PrettyFormatOptions extends SnapshotFormat {}

              property compareKeys

              compareKeys?: CompareKeys;

                property plugins

                plugins?: Plugins;

                  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;
                  };
                  };

                    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;
                      maxWidth: 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 OptionsReceived

                            type OptionsReceived = PrettyFormatOptions;

                              type Plugin

                              type Plugin_2 = NewPlugin | OldPlugin;

                                type Plugins

                                type Plugins = Array<Plugin_2>;

                                  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 = Options['theme'];

                                        Package Files (1)

                                        Dependencies (4)

                                        Dev Dependencies (9)

                                        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>