pretty-format
- Version 29.7.0
- Published
- 60.7 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: { callToJSON: true; compareKeys: undefined; escapeRegex: false; escapeString: true; highlight: false; indent: number; maxDepth: number; maxWidth: number; min: false; plugins: never[]; printBasicPrototype: true; printFunctionName: true; theme: Required<{ readonly comment?: string | undefined; readonly content?: string | undefined; readonly prop?: string | undefined; readonly tag?: string | undefined; readonly value?: string | undefined; }>;};
variable plugins
const plugins: { AsymmetricMatcher: 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
objectParameter 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 Omit<SnapshotFormat, 'compareKeys'> {}
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) | null | 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 (3)
Dev Dependencies (8)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto 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>
- Updated .
Package analyzed in 3543 ms. - Missing or incorrect documentation? Open an issue for this package.