Files
bun.sh/docs/guides/write-file/stdout.md
2024-09-10 15:11:16 -07:00

22 lines
596 B
Markdown

---
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()`](https://bun.sh/docs/api/file-io#writing-files-bun-write).
```ts
await Bun.write(Bun.stdout, "Lorem ipsum");
```
---
See [Docs > API > File I/O](https://bun.sh/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.