mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
feat(std/node): add util.inspect (#6833)
This commit is contained in:
parent
3d70a2b94e
commit
452693256c
2 changed files with 19 additions and 1 deletions
|
@ -4,6 +4,16 @@ import * as types from "./_util/_util_types.ts";
|
|||
|
||||
export { types };
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function inspect(object: unknown, ...opts: any): string {
|
||||
return Deno.inspect(object, {
|
||||
depth: opts.depth ?? 4,
|
||||
iterableLimit: opts.iterableLimit ?? 100,
|
||||
compact: !!(opts.compact ?? true),
|
||||
sorted: !!(opts.sorted ?? false),
|
||||
});
|
||||
}
|
||||
|
||||
export function isArray(value: unknown): boolean {
|
||||
return Array.isArray(value);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
import { assert } from "../testing/asserts.ts";
|
||||
import { assert, assertEquals } from "../testing/asserts.ts";
|
||||
import { stripColor } from "../fmt/colors.ts";
|
||||
import * as util from "./util.ts";
|
||||
|
||||
Deno.test({
|
||||
name: "[util] inspect",
|
||||
fn() {
|
||||
assertEquals(stripColor(util.inspect({ foo: 123 })), "{ foo: 123 }");
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "[util] isBoolean",
|
||||
fn() {
|
||||
|
|
Loading…
Add table
Reference in a new issue