Skip to content

Commit

Permalink
3319e89cd42cf66cac3ec68a0e7f51223587534a
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 3, 2024
1 parent f25a68d commit 658eb05
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 62 deletions.
5 changes: 1 addition & 4 deletions esm/storage/1_storage_memory.d.ts
Original file line number Diff line number Diff line change
@@ -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<string, unknown>;
protected messageMap: CacheMap<string, unknown>;
constructor(authString?: string);
get isMemoryStorage(): boolean;
initialize(): Promise<void>;
getMap(key: readonly StorageKeyPart[]): Map<string, unknown>;
getMaps(): [Map<string, unknown>, Map<string, unknown>];
branch(id: string): Storage;
get supportsFiles(): boolean;
get<T>(key: readonly StorageKeyPart[]): T | null;
Expand Down
34 changes: 7 additions & 27 deletions esm/storage/1_storage_memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
};
5 changes: 1 addition & 4 deletions script/storage/1_storage_memory.d.ts
Original file line number Diff line number Diff line change
@@ -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<string, unknown>;
protected messageMap: CacheMap<string, unknown>;
constructor(authString?: string);
get isMemoryStorage(): boolean;
initialize(): Promise<void>;
getMap(key: readonly StorageKeyPart[]): Map<string, unknown>;
getMaps(): [Map<string, unknown>, Map<string, unknown>];
branch(id: string): Storage;
get supportsFiles(): boolean;
get<T>(key: readonly StorageKeyPart[]): T | null;
Expand Down
34 changes: 7 additions & 27 deletions script/storage/1_storage_memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
};

0 comments on commit 658eb05

Please sign in to comment.