-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Map-like interface Deno.env #4942
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this API. Leaving it to @piscisaureus for final review
I was wondering if we could call it entries instead of getAll while still returning an object. Isn’t that an iterator still? |
entries() return iterator object (the one that has next() method); plain objects don't have iterator implementation EDIT: Oooops I somehow edited @ry's comment by mistake |
A couple of other possibilities:
none of these are particularly great... |
The best one would be
Just for reference; in Rust: let env = env::vars(); (returns interator)
let envVar = env::var("my_var");
env::set_var("my_var", "my_value");
env::remove_var("my_car"); |
I agree that entries is ideal too. What if we just did |
Wouldn't the |
After further discussion we've settled on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks @SyrupThinker !
What's the benefit of the Map-like interface over
|
@jakajancar We want to make it look less like you're updating some object - but rather calling functions which have side-effects. In particular, in Windows the env vars are not case sensitive. |
Ah, the Windows situation is reason enough. That would indeed look odd if properties changed in unexpected ways. Thanks for the explanation! |
As noted in #4933