@aws-amplify/core
Version:
Core category of aws-amplify
35 lines (33 loc) • 754 B
JavaScript
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
/**
* @internal
*/
class InMemoryStorage {
constructor() {
this.storage = new Map();
}
get length() {
return this.storage.size;
}
key(index) {
if (index > this.length - 1) {
return null;
}
return Array.from(this.storage.keys())[index];
}
setItem(key, value) {
this.storage.set(key, value);
}
getItem(key) {
return this.storage.get(key) ?? null;
}
removeItem(key) {
this.storage.delete(key);
}
clear() {
this.storage.clear();
}
}
export { InMemoryStorage };
//# sourceMappingURL=InMemoryStorage.mjs.map