From 3a45f2c71bb17fbad0168fa76b32ae0c8ee67935 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Mon, 21 Aug 2023 21:34:03 -0700 Subject: Docs and types for v0.8.0 (#4199) * Improve test documentation * Update nodejs compat docs with tty * Add debugger guide * Document Bun.inspect.custom, improve bun test nav * Address reviews * Update Bun.file types * Add Nuxt guide * Add tty types --- docs/api/utils.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'docs/api/utils.md') diff --git a/docs/api/utils.md b/docs/api/utils.md index 2723edf7c..8b166e3e8 100644 --- a/docs/api/utils.md +++ b/docs/api/utils.md @@ -428,6 +428,21 @@ const str = Bun.inspect(arr); // => "Uint8Array(3) [ 1, 2, 3 ]" ``` +## `Bun.inspect.custom` + +This is the symbol that Bun uses to implement `Bun.inspect`. You can override this to customize how your objects are printed. It is identical to `util.inspect.custom` in Node.js. + +```ts +class Foo { + [Bun.inspect.custom]() { + return "foo"; + } +} + +const foo = new Foo(); +console.log(foo); // => "foo" +``` + ## `Bun.nanoseconds()` Returns the number of nanoseconds since the current `bun` process started, as a `number`. Useful for high-precision timing and benchmarking. -- cgit v1.2.3