Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bun.file().writer should work with Symbol.dispose #8444

Open
webdev03 opened this issue Jan 24, 2024 · 0 comments
Open

Bun.file().writer should work with Symbol.dispose #8444

webdev03 opened this issue Jan 24, 2024 · 0 comments
Labels
bun.js Something to do with a Bun-specific API enhancement New feature or request

Comments

@webdev03
Copy link

What is the problem this feature would solve?

Currently, as far as I know, there should be a writer.end() in code using Bun.file once it doesn't need to use the file descriptor. The new using keyword reduces the need for this by automatically calling a function once the variable is out of scope, making code cleaner.

What is the feature you are proposing to solve the problem?

I propose making Bun.file().writer compatible with this new feature.

const file = Bun.file("./example.txt");
{
  using writer = file.writer();
  writer.write("Hi!");
}
// Automatically removes the file descriptor

What alternatives have you considered?

No response

@webdev03 webdev03 added the enhancement New feature or request label Jan 24, 2024
@Electroid Electroid added the bun.js Something to do with a Bun-specific API label Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bun.js Something to do with a Bun-specific API enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants