diff options
author | 2023-07-26 14:59:39 -0700 | |
---|---|---|
committer | 2023-07-26 14:59:39 -0700 | |
commit | 4c89c60867591b50e0b31bf5009fd5ad6a3cebe1 (patch) | |
tree | fc1d2f47309c0345a850933496baa40d94bfdcbb /docs/guides/write-file/stdout.md | |
parent | 6bfee02301a2e2a0b79339974af0445eb5a2688f (diff) | |
download | bun-4c89c60867591b50e0b31bf5009fd5ad6a3cebe1.tar.gz bun-4c89c60867591b50e0b31bf5009fd5ad6a3cebe1.tar.zst bun-4c89c60867591b50e0b31bf5009fd5ad6a3cebe1.zip |
Add files (#3826)
Diffstat (limited to 'docs/guides/write-file/stdout.md')
-rw-r--r-- | docs/guides/write-file/stdout.md | 21 |
1 files changed, 21 insertions, 0 deletions
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()`. |