From 658eb0556a01c78d8892f3370ef1afa41753d8ad Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:37:59 +0000 Subject: [PATCH] 3319e89cd42cf66cac3ec68a0e7f51223587534a --- esm/storage/1_storage_memory.d.ts | 5 +--- esm/storage/1_storage_memory.js | 34 ++++++---------------------- script/storage/1_storage_memory.d.ts | 5 +--- script/storage/1_storage_memory.js | 34 ++++++---------------------- 4 files changed, 16 insertions(+), 62 deletions(-) diff --git a/esm/storage/1_storage_memory.d.ts b/esm/storage/1_storage_memory.d.ts index ced45b8..bd924c1 100644 --- a/esm/storage/1_storage_memory.d.ts +++ b/esm/storage/1_storage_memory.d.ts @@ -1,14 +1,11 @@ -import { CacheMap, MaybePromise } from "../1_utilities.js"; +import { MaybePromise } from "../1_utilities.js"; import { GetManyFilter, Storage, StorageKeyPart } from "./0_storage.js"; export declare class StorageMemory extends Storage implements Storage { #private; protected map: Map; - protected messageMap: CacheMap; constructor(authString?: string); get isMemoryStorage(): boolean; initialize(): Promise; - getMap(key: readonly StorageKeyPart[]): Map; - getMaps(): [Map, Map]; branch(id: string): Storage; get supportsFiles(): boolean; get(key: readonly StorageKeyPart[]): T | null; diff --git a/esm/storage/1_storage_memory.js b/esm/storage/1_storage_memory.js index d3dda24..546dedf 100644 --- a/esm/storage/1_storage_memory.js +++ b/esm/storage/1_storage_memory.js @@ -10,7 +10,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function ( return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _StorageMemory_instances, _StorageMemory_id, _StorageMemory_authString, _StorageMemory_fixKey, _StorageMemory_getEntries; -import { CacheMap } from "../1_utilities.js"; import { Storage } from "./0_storage.js"; import { fromString, isInRange, toString } from "./0_utilities.js"; export class StorageMemory extends Storage { @@ -23,12 +22,6 @@ export class StorageMemory extends Storage { writable: true, value: new Map() }); - Object.defineProperty(this, "messageMap", { - enumerable: true, - configurable: true, - writable: true, - value: new CacheMap(30000) - }); _StorageMemory_id.set(this, null); _StorageMemory_authString.set(this, void 0); __classPrivateFieldSet(this, _StorageMemory_authString, authString, "f"); @@ -41,17 +34,6 @@ export class StorageMemory extends Storage { await this.importAuthString(__classPrivateFieldGet(this, _StorageMemory_authString, "f")); } } - getMap(key) { - if (key[0] == "messages.messages") { - return this.messageMap; - } - else { - return this.map; - } - } - getMaps() { - return [this.map, this.messageMap]; - } branch(id) { const storage = new StorageMemory(); __classPrivateFieldSet(storage, _StorageMemory_id, id, "f"); @@ -62,7 +44,7 @@ export class StorageMemory extends Storage { } get(key) { key = __classPrivateFieldGet(this, _StorageMemory_instances, "m", _StorageMemory_fixKey).call(this, key); - return this.getMap(key).get(toString(key)) ?? null; + return this.map.get(toString(key)) ?? null; } *getMany(filter, params) { let entries = __classPrivateFieldGet(this, _StorageMemory_instances, "m", _StorageMemory_getEntries).call(this); @@ -95,10 +77,10 @@ export class StorageMemory extends Storage { key_ = __classPrivateFieldGet(this, _StorageMemory_instances, "m", _StorageMemory_fixKey).call(this, key_); const key = toString(key_); if (value != null) { - this.getMap(key_).set(key, value); + this.map.set(key, value); } else { - this.getMap(key_).delete(key); + this.map.delete(key); } } incr(key, by) { @@ -114,13 +96,11 @@ _StorageMemory_id = new WeakMap(), _StorageMemory_authString = new WeakMap(), _S } }, _StorageMemory_getEntries = function _StorageMemory_getEntries() { const entries = new Array(); - for (const map of this.getMaps()) { - for (const entry of map.entries()) { - if (__classPrivateFieldGet(this, _StorageMemory_id, "f") !== null && !entry[0].startsWith("__S" + __classPrivateFieldGet(this, _StorageMemory_id, "f"))) { - continue; - } - entries.push(entry); + for (const entry of this.map.entries()) { + if (__classPrivateFieldGet(this, _StorageMemory_id, "f") !== null && !entry[0].startsWith("__S" + __classPrivateFieldGet(this, _StorageMemory_id, "f"))) { + continue; } + entries.push(entry); } return entries; }; diff --git a/script/storage/1_storage_memory.d.ts b/script/storage/1_storage_memory.d.ts index ced45b8..bd924c1 100644 --- a/script/storage/1_storage_memory.d.ts +++ b/script/storage/1_storage_memory.d.ts @@ -1,14 +1,11 @@ -import { CacheMap, MaybePromise } from "../1_utilities.js"; +import { MaybePromise } from "../1_utilities.js"; import { GetManyFilter, Storage, StorageKeyPart } from "./0_storage.js"; export declare class StorageMemory extends Storage implements Storage { #private; protected map: Map; - protected messageMap: CacheMap; constructor(authString?: string); get isMemoryStorage(): boolean; initialize(): Promise; - getMap(key: readonly StorageKeyPart[]): Map; - getMaps(): [Map, Map]; branch(id: string): Storage; get supportsFiles(): boolean; get(key: readonly StorageKeyPart[]): T | null; diff --git a/script/storage/1_storage_memory.js b/script/storage/1_storage_memory.js index fc13e91..20cd711 100644 --- a/script/storage/1_storage_memory.js +++ b/script/storage/1_storage_memory.js @@ -13,7 +13,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function ( var _StorageMemory_instances, _StorageMemory_id, _StorageMemory_authString, _StorageMemory_fixKey, _StorageMemory_getEntries; Object.defineProperty(exports, "__esModule", { value: true }); exports.StorageMemory = void 0; -const _1_utilities_js_1 = require("../1_utilities.js"); const _0_storage_js_1 = require("./0_storage.js"); const _0_utilities_js_1 = require("./0_utilities.js"); class StorageMemory extends _0_storage_js_1.Storage { @@ -26,12 +25,6 @@ class StorageMemory extends _0_storage_js_1.Storage { writable: true, value: new Map() }); - Object.defineProperty(this, "messageMap", { - enumerable: true, - configurable: true, - writable: true, - value: new _1_utilities_js_1.CacheMap(30000) - }); _StorageMemory_id.set(this, null); _StorageMemory_authString.set(this, void 0); __classPrivateFieldSet(this, _StorageMemory_authString, authString, "f"); @@ -44,17 +37,6 @@ class StorageMemory extends _0_storage_js_1.Storage { await this.importAuthString(__classPrivateFieldGet(this, _StorageMemory_authString, "f")); } } - getMap(key) { - if (key[0] == "messages.messages") { - return this.messageMap; - } - else { - return this.map; - } - } - getMaps() { - return [this.map, this.messageMap]; - } branch(id) { const storage = new StorageMemory(); __classPrivateFieldSet(storage, _StorageMemory_id, id, "f"); @@ -65,7 +47,7 @@ class StorageMemory extends _0_storage_js_1.Storage { } get(key) { key = __classPrivateFieldGet(this, _StorageMemory_instances, "m", _StorageMemory_fixKey).call(this, key); - return this.getMap(key).get((0, _0_utilities_js_1.toString)(key)) ?? null; + return this.map.get((0, _0_utilities_js_1.toString)(key)) ?? null; } *getMany(filter, params) { let entries = __classPrivateFieldGet(this, _StorageMemory_instances, "m", _StorageMemory_getEntries).call(this); @@ -98,10 +80,10 @@ class StorageMemory extends _0_storage_js_1.Storage { key_ = __classPrivateFieldGet(this, _StorageMemory_instances, "m", _StorageMemory_fixKey).call(this, key_); const key = (0, _0_utilities_js_1.toString)(key_); if (value != null) { - this.getMap(key_).set(key, value); + this.map.set(key, value); } else { - this.getMap(key_).delete(key); + this.map.delete(key); } } incr(key, by) { @@ -118,13 +100,11 @@ _StorageMemory_id = new WeakMap(), _StorageMemory_authString = new WeakMap(), _S } }, _StorageMemory_getEntries = function _StorageMemory_getEntries() { const entries = new Array(); - for (const map of this.getMaps()) { - for (const entry of map.entries()) { - if (__classPrivateFieldGet(this, _StorageMemory_id, "f") !== null && !entry[0].startsWith("__S" + __classPrivateFieldGet(this, _StorageMemory_id, "f"))) { - continue; - } - entries.push(entry); + for (const entry of this.map.entries()) { + if (__classPrivateFieldGet(this, _StorageMemory_id, "f") !== null && !entry[0].startsWith("__S" + __classPrivateFieldGet(this, _StorageMemory_id, "f"))) { + continue; } + entries.push(entry); } return entries; };