0
0
Fork 0
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:
Benjamin Lupton 2020-08-13 04:03:51 +10:00 committed by GitHub
parent 3d70a2b94e
commit 452693256c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

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

View file

@ -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() {