EasyPythonJavaScriptTypeScript

Merge Env Variables

Node.jsObjectsConfig

Merge multiple env-var objects into one. Later objects override earlier ones,
but null values do not override existing keys (only present, non-null
keys win).

solve([{ A: '1' }, { A: null, B: '2' }]){ A: '1', B: '2' }.

Sample tests

Test #1Null does not override
Input: [[{"A":"1"},{"A":null}]]
Output: {"A":"1"}
Test #2No envs
Input: [[]]
Output: {}
Test #3Mixed
Input: [[{"A":"1","B":"2"},{"A":null,"B":"3","C":"4"}]]
Output: {"A":"1","B":"3","C":"4"}
Test #4Two distinct sets
Input: [[{"A":"1"},{"B":"2"}]]
Output: {"A":"1","B":"2"}
Test #5Override
Input: [[{"A":"1"},{"A":"2"}]]
Output: {"A":"2"}