forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmementos.ts
More file actions
26 lines (25 loc) · 989 Bytes
/
mementos.ts
File metadata and controls
26 lines (25 loc) · 989 Bytes
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
import { injectable } from 'inversify';
import { Memento } from 'vscode';
@injectable()
export class MockMemento implements Memento {
// Note: This has to be called _value so that it matches
// what VS code has for a memento. We use this to eliminate a bad bug
// with writing too much data to global storage. See bug https://github.com/microsoft/vscode-python/issues/9159
private _value: Record<string, {}> = {};
// @ts-ignore
// tslint:disable-next-line:no-any
public get(key: any, defaultValue?: any);
public get<T>(key: string, defaultValue?: T): T {
const exists = this._value.hasOwnProperty(key);
// tslint:disable-next-line:no-any
return exists ? this._value[key] : (defaultValue! as any);
}
// tslint:disable-next-line:no-any
public update(key: string, value: any): Thenable<void> {
this._value[key] = value;
return Promise.resolve();
}
public clear() {
this._value = {};
}
}