forked from authts/oidc-client-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInMemoryWebStorage.ts
More file actions
40 lines (31 loc) · 1016 Bytes
/
Copy pathInMemoryWebStorage.ts
File metadata and controls
40 lines (31 loc) · 1016 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
import { Log } from "./utils";
export class InMemoryWebStorage implements Storage {
private _data: Record<string, any>;
constructor() {
this._data = {};
}
clear(): void {
Log.debug("InMemoryWebStorage.clear");
this._data = {};
}
getItem(key: string) {
Log.debug("InMemoryWebStorage.getItem", key);
return this._data[key];
}
setItem(key: string, value: any) {
Log.debug("InMemoryWebStorage.setItem", key);
this._data[key] = value;
}
removeItem(key: string) {
Log.debug("InMemoryWebStorage.removeItem", key);
delete this._data[key];
}
get length() {
return Object.getOwnPropertyNames(this._data).length;
}
key(index: number) {
return Object.getOwnPropertyNames(this._data)[index];
}
}