diff options
author | 2023-08-21 21:34:03 -0700 | |
---|---|---|
committer | 2023-08-21 21:34:03 -0700 | |
commit | 3a45f2c71bb17fbad0168fa76b32ae0c8ee67935 (patch) | |
tree | 2b02a163ff489349108ad99c211e65ed77209554 /docs/api | |
parent | 9eeb7bdbff72997709a9a4c6afb2910830d29842 (diff) | |
download | bun-3a45f2c71bb17fbad0168fa76b32ae0c8ee67935.tar.gz bun-3a45f2c71bb17fbad0168fa76b32ae0c8ee67935.tar.zst bun-3a45f2c71bb17fbad0168fa76b32ae0c8ee67935.zip |
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
Diffstat (limited to 'docs/api')
-rw-r--r-- | docs/api/utils.md | 15 |
1 files changed, 15 insertions, 0 deletions
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. |