deno.land / std@0.224.0 / internal / format.ts

format.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.
/** * Converts the input into a string. Objects, Sets and Maps are sorted so as to * make tests less flaky * @param v Value to be formatted */export function format(v: unknown): string { // deno-lint-ignore no-explicit-any const { Deno } = globalThis as any; return typeof Deno?.inspect === "function" ? Deno.inspect(v, { depth: Infinity, sorted: true, trailingComma: true, compact: false, iterableLimit: Infinity, // getters should be true in assertEquals. getters: true, strAbbreviateSize: Infinity, }) : `"${String(v).replace(/(?=["\\])/g, "\\")}"`;}
std

Version Info

Tagged at
6 months ago