-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
29 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,19 @@ | ||
import { type Value } from "../value/index.js" | ||
|
||
export class Env { | ||
values: Map<string, Value> | ||
export type Env = Map<string, Value> | ||
|
||
constructor(options: { values: Map<string, Value> }) { | ||
this.values = options.values | ||
} | ||
|
||
static init(): Env { | ||
return new Env({ | ||
values: new Map(), | ||
}) | ||
} | ||
export function envEmpty(): Env { | ||
return new Map() | ||
} | ||
|
||
get names(): Array<string> { | ||
return Array.from(this.values.keys()) | ||
} | ||
export function envNames(env: Env): Array<string> { | ||
return Array.from(env.keys()) | ||
} | ||
|
||
findValue(name: string): undefined | Value { | ||
return this.values.get(name) | ||
} | ||
export function envFindValue(env: Env, name: string): undefined | Value { | ||
return env.get(name) | ||
} | ||
|
||
extend(name: string, value: Value): Env { | ||
return new Env({ | ||
...this, | ||
values: new Map([...this.values, [name, value]]), | ||
}) | ||
} | ||
export function envExtend(env: Env, name: string, value: Value): Env { | ||
return new Map([...env, [name, value]]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters