Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 3x 3x 3x 3x 2990x 2990x 2990x 969x 90x 90x 90x 16x 16x | import {get} from '@jsonjoy.com/json-pointer/lib/get';
import {toPath} from '@jsonjoy.com/json-pointer/lib/util';
import {validateJsonPointer} from '@jsonjoy.com/json-pointer/lib/validate';
export class Vars {
protected readonly vars: Map<string, unknown> = new Map();
constructor(public readonly env: unknown) {
this.env = env;
}
public get(name: string): unknown {
if (!name) return this.env;
return this.vars.get(name);
}
public set(name: string, value: unknown): void {
Iif (!name) throw new Error('Invalid varname.');
this.vars.set(name, value);
}
public has(name: string): boolean {
Iif (!name) return true;
return this.vars.has(name);
}
public del(name: string): boolean {
Iif (!name) throw new Error('Invalid varname.');
return this.vars.delete(name);
}
public find(name: string, pointer: string): unknown {
const data = this.get(name);
validateJsonPointer(pointer);
const path = toPath(pointer);
return get(data, path);
}
}
|