From 721a4ad59d4a8bdd8470d6b98839137f14c84ba9 Mon Sep 17 00:00:00 2001 From: Valentin Anger Date: Wed, 29 Apr 2020 20:48:19 +0200 Subject: BREAKING: Map-like interface for Deno.env (#4942) --- cli/js/ops/os.ts | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'cli/js/ops') diff --git a/cli/js/ops/os.ts b/cli/js/ops/os.ts index e01718c8c..30aa6d0d4 100644 --- a/cli/js/ops/os.ts +++ b/cli/js/ops/os.ts @@ -27,22 +27,13 @@ function getEnv(key: string): string | undefined { return sendSync("op_get_env", { key })[0]; } -export function env(): { [index: string]: string }; -export function env(key: string): string | undefined; -export function env( - key?: string -): { [index: string]: string } | string | undefined { - if (key) { - return getEnv(key); - } - const env = sendSync("op_env"); - return new Proxy(env, { - set(obj, prop: string, value: string): boolean { - setEnv(prop, value); - return Reflect.set(obj, prop, value); - }, - }); -} +export const env = { + get: getEnv, + toObject(): { [key: string]: string } { + return sendSync("op_env"); + }, + set: setEnv, +}; type DirKind = | "home" -- cgit v1.2.3