From 4c89c60867591b50e0b31bf5009fd5ad6a3cebe1 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Wed, 26 Jul 2023 14:59:39 -0700 Subject: Add files (#3826) --- docs/guides/write-file/stdout.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 docs/guides/write-file/stdout.md (limited to 'docs/guides/write-file/stdout.md') diff --git a/docs/guides/write-file/stdout.md b/docs/guides/write-file/stdout.md new file mode 100644 index 000000000..00fa11a60 --- /dev/null +++ b/docs/guides/write-file/stdout.md @@ -0,0 +1,21 @@ +--- +name: Write to stdout +--- + +The `console.log` function writes to `stdout`. It will automatically append a line break at the end of the printed data. + +```ts +console.log("Lorem ipsum"); +``` + +--- + +For more advanced use cases, Bun exposes `stdout` as a `BunFile` via the `Bun.stdout` property. This can be used as a destination for [`Bun.write()`](/docs/api/file-io#writing-files-bun-write). + +```ts +await Bun.write(Bun.stdout, "Lorem ipsum"); +``` + +--- + +See [Docs > API > File I/O](/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. -- cgit v1.2.3