Reputation: 26122
Say I have extend function that
extend(obj1, obj2) -> creates new object does not mutate sources
According to documentation process.env is just an object, but I wonder is it save operation to do the followng:
process.env = extend(process.env, {MY_SETTING: 'Something'})
so process.env will be completely replaced new object with the same properties?
Upvotes: 0
Views: 228
Reputation: 13570
It's probably safe, but there is no good reason to do it. env
is defined in C++ code (https://github.com/joyent/node/blob/v0.10.28-release/src/node.cc#L2324-L2332). As you can see accessing each property actually involves getenv
invocation, which has O(n) complexity, so enumeration and copying of whole env
object would be quite inefficient.
Upvotes: 2