sliftutils 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,17 @@
1
- export declare class URLParamStr {
2
- readonly urlKey: string;
3
- private state;
4
- lastSetValue: string;
5
- constructor(urlKey: string);
6
- forceUpdate(): void;
7
- get(): string;
8
- set(value: string): void;
9
- get value(): string;
10
- set value(value: string);
1
+ export declare class URLParam<T = unknown> {
2
+ readonly key: string;
3
+ private defaultValue;
4
+ constructor(key: string, defaultValue?: T);
5
+ valueSeqNum: {
6
+ value: number;
7
+ };
8
+ get(): T;
9
+ set(value: T): void;
10
+ reset(): void;
11
+ getOverride(value: T): [string, string];
12
+ get value(): T;
13
+ set value(value: T);
11
14
  }
12
- export declare function batchUrlUpdate<T>(code: () => T): T;
13
- export declare function createLink(params: [URLParamStr, string][]): string;
15
+ export declare function getResolvedParam(param: [URLParam, unknown] | [string, string]): [string, string];
16
+ export declare function batchURLParamUpdate(params: ([URLParam, unknown] | [string, string])[]): void;
17
+ export declare function getCurrentUrl(): string;
@@ -1,84 +1,101 @@
1
1
  import { isNode } from "typesafecss";
2
2
  import { observable } from "mobx";
3
+ import { throttleFunction } from "socket-function/src/misc";
4
+ import { niceParse, niceStringify } from "./niceStringify";
3
5
 
4
- let allParams: URLParamStr[] = [];
6
+ let urlParamLookup = new Map<string, URLParam<unknown>>();
7
+ let pauseUpdate = false;
5
8
 
6
- let updated: URLParamStr[] = [];
7
-
8
- export class URLParamStr {
9
- private state = observable({
10
- seqNum: 0
11
- });
12
- public lastSetValue = "";
13
- constructor(public readonly urlKey: string) {
14
- allParams.push(this);
9
+ export class URLParam<T = unknown> {
10
+ constructor(public readonly key: string, private defaultValue: T = "" as any) {
11
+ urlParamLookup.set(key, this);
15
12
  }
16
- public forceUpdate() {
17
- this.state.seqNum++;
13
+ valueSeqNum = observable({ value: 1 });
14
+ public get(): T {
15
+ urlBackSeqNum.value;
16
+ this.valueSeqNum.value;
17
+ let value = new URL(getCurrentUrl()).searchParams.get(this.key);
18
+ if (value === null) {
19
+ return this.defaultValue;
20
+ }
21
+ return niceParse(value) as T;
18
22
  }
19
-
20
- public get() {
21
- this.state.seqNum;
22
- return new URLSearchParams(window.location.search).get(this.urlKey) || "";
23
+ public set(value: T) {
24
+ let url = new URL(getCurrentUrl());
25
+ if (value === this.defaultValue) {
26
+ url.searchParams.delete(this.key);
27
+ } else {
28
+ url.searchParams.set(this.key, niceStringify(value));
29
+ }
30
+ if (!pauseUpdate) {
31
+ void throttledUrlPush(url.toString());
32
+ this.valueSeqNum.value++;
33
+ }
23
34
  }
24
- public set(value: string) {
25
- if (value === this.get()) return;
26
- this.lastSetValue = value;
27
- batchUrlUpdate(() => {
28
- updated.push(this);
29
- });
30
- this.state.seqNum++;
35
+ public reset() {
36
+ let url = new URL(getCurrentUrl());
37
+ url.searchParams.delete(this.key);
38
+ if (!pauseUpdate) {
39
+ void throttledUrlPush(url.toString());
40
+ this.valueSeqNum.value++;
41
+ }
42
+ }
43
+
44
+ public getOverride(value: T): [string, string] {
45
+ return [this.key, value as any];
31
46
  }
32
47
 
33
48
  public get value() {
34
49
  return this.get();
35
50
  }
36
- public set value(value: string) {
51
+ public set value(value: T) {
37
52
  this.set(value);
38
53
  }
39
54
  }
40
55
 
41
- let inBatchUpdate = false;
42
- export function batchUrlUpdate<T>(code: () => T): T {
43
- if (inBatchUpdate) return code();
44
- inBatchUpdate = true;
56
+ export function getResolvedParam(param: [URLParam, unknown] | [string, string]): [string, string] {
57
+ if (typeof param[0] === "string") {
58
+ return [param[0], niceStringify(param[1])];
59
+ }
60
+ return [param[0].key, niceStringify(param[1])];
61
+ }
62
+ export function batchURLParamUpdate(params: ([URLParam, unknown] | [string, string])[]) {
63
+ let resolvedParams = params.map(getResolvedParam);
64
+ pauseUpdate = true;
65
+ let url = new URL(location.href);
45
66
  try {
46
- return code();
47
- } finally {
48
- inBatchUpdate = false;
49
-
50
- let prevUpdated = updated;
51
- updated = [];
52
- let searchParams = new URLSearchParams(window.location.search);
53
- for (let obj of prevUpdated) {
54
- searchParams.set(obj.urlKey, obj.lastSetValue);
55
- }
56
- let newURL = "?" + searchParams.toString();
57
- if (window.location.hash) {
58
- newURL += window.location.hash;
67
+ for (let [key, value] of resolvedParams) {
68
+ url.searchParams.set(key, value);
69
+ let urlParam = urlParamLookup.get(key);
70
+ urlParam?.set(niceParse(value));
59
71
  }
60
- window.history.pushState({}, "", newURL);
72
+ } finally {
73
+ pauseUpdate = false;
61
74
  }
75
+ urlBackSeqNum.value++;
76
+ void throttledUrlPush(url.toString());
62
77
  }
63
78
 
64
- export function createLink(params: [URLParamStr, string][]) {
65
- let searchParams = new URLSearchParams(window.location.search);
66
- for (let [param, value] of params) {
67
- searchParams.set(param.urlKey, value);
68
- }
69
- let newURL = "?" + searchParams.toString();
70
- if (window.location.hash) {
71
- newURL += window.location.hash;
72
- }
73
- return newURL;
79
+ export function getCurrentUrl() {
80
+ return currentBatchedUrl ?? location.href;
74
81
  }
75
82
 
83
+
84
+ let currentBatchedUrl: string | undefined;
85
+ function throttledUrlPush(url: string) {
86
+ history.pushState({}, "", url);
87
+ //currentBatchedUrl = url;
88
+ // NOTE: Stopped throttling, so when you click on links, it immediately updates the selected state.
89
+ //void throttledUrlPushBase(url);
90
+ }
91
+ const throttledUrlPushBase = throttleFunction(1000, (url: string) => {
92
+ currentBatchedUrl = undefined;
93
+ history.pushState({}, "", url);
94
+ });
95
+
96
+ let urlBackSeqNum = observable({ value: 1 });
76
97
  if (!isNode()) {
77
- // Watch for url push states
78
98
  window.addEventListener("popstate", () => {
79
- // Force all to update, in case their param changed
80
- for (let param of allParams) {
81
- param.forceUpdate();
82
- }
99
+ urlBackSeqNum.value++;
83
100
  });
84
101
  }
@@ -0,0 +1,5 @@
1
+ export declare const niceStringifyTrue = "";
2
+ export declare const niceStringifyNan = "{NaN}";
3
+ export declare const niceStringifyUndefined = "{Undefined}";
4
+ export declare function niceStringify(value: unknown): string;
5
+ export declare function niceParse(str: string | undefined, noSpecialTrue?: boolean): unknown;
@@ -0,0 +1,83 @@
1
+ // true => ""
2
+ // "" => JSON.stringify("")
3
+
4
+ export const niceStringifyTrue = "";
5
+ // Starting/ending with a JSON character means anything string that looks like this
6
+ // will be encoded like: `"{Nan`, and it is impossible for an object to serialize to look like this.
7
+ export const niceStringifyNan = `{NaN}`;
8
+ export const niceStringifyUndefined = `{Undefined}`;
9
+
10
+
11
+ // BUG: This is actually broken for hex strings. Hex strings may sometimes be entirely numbers,
12
+ // which means they will randomly change type.
13
+ function looksLikeJSON(str: string) {
14
+ return (
15
+ str === "null"
16
+ || str === "true"
17
+ || str === "false"
18
+ || str[0] === `"` && str[str.length - 1] === `"`
19
+ || str[0] === `[` && str[str.length - 1] === `]`
20
+ || str[0] === `{` && str[str.length - 1] === `}`
21
+ || (48 <= str.charCodeAt(0) && str.charCodeAt(0) <= 57)
22
+ || str.length > 1 && str[0] === "-" && (48 <= str.charCodeAt(1) && str.charCodeAt(1) <= 57)
23
+ || str === niceStringifyTrue
24
+ || str === niceStringifyUndefined
25
+ );
26
+ }
27
+
28
+ export function niceStringify(value: unknown): string {
29
+ if (value === undefined) {
30
+ return niceStringifyUndefined;
31
+ }
32
+ if (value === true) return niceStringifyTrue;
33
+ if (Number.isNaN(value)) return niceStringifyNan;
34
+
35
+ // Any strings that don't look like JSON, don't need to encoded as JSON, and can instead
36
+ // just be stored as strings.
37
+ if (typeof value === "string" && !looksLikeJSON(value)) {
38
+ return value;
39
+ }
40
+
41
+
42
+ let str = JSON.stringify(value);
43
+ if (typeof value !== "object") {
44
+ let testParse = niceParse(str);
45
+ if (testParse !== value) {
46
+ console.log(`niceStringify did not reverse correctly. Should have received ${JSON.stringify(value)}, did received ${JSON.stringify(testParse)}`);
47
+ debugger;
48
+ }
49
+ }
50
+
51
+ return str;
52
+ }
53
+
54
+ export function niceParse(str: string | undefined, noSpecialTrue = false): unknown {
55
+ if (str === undefined) {
56
+ return undefined;
57
+ }
58
+ if (str === niceStringifyTrue && !noSpecialTrue) return true;
59
+ if (str === niceStringifyNan) return Number.NaN;
60
+ if (str === niceStringifyUndefined) return undefined;
61
+ if (str === "") return str;
62
+
63
+ if (looksLikeJSON(str)) {
64
+ try {
65
+ return JSON.parse(str);
66
+ } catch { }
67
+ }
68
+ return str;
69
+ }
70
+
71
+ /*
72
+
73
+ function setFromUrlValue(key: string, valueJSON: string) {
74
+ if(isMaybeJSON(valueJSON)) {
75
+ try {
76
+ values[key] = JSON.parse(valueJSON);
77
+ return;
78
+ } catch { }
79
+ }
80
+ // Always set it, if it isn't JSON, just assume it is raw text.
81
+ values[key] = valueJSON;
82
+ }
83
+ */
@@ -0,0 +1,2 @@
1
+ import { StorageSync } from "./StorageObservable";
2
+ export declare function newCachedStrStorage<T>(folder: string, getValue: (key: string) => Promise<T>): StorageSync<T>;
@@ -0,0 +1,14 @@
1
+ import { IStorage } from "./IStorage";
2
+ export declare class DelayedStorage<T> implements IStorage<T> {
3
+ private storage;
4
+ constructor(storage: Promise<IStorage<T>>);
5
+ get(key: string): Promise<T | undefined>;
6
+ set(key: string, value: T): Promise<void>;
7
+ remove(key: string): Promise<void>;
8
+ getKeys(): Promise<string[]>;
9
+ getInfo(key: string): Promise<{
10
+ size: number;
11
+ lastModified: number;
12
+ } | undefined>;
13
+ reset(): Promise<void>;
14
+ }
@@ -0,0 +1,99 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { IStorage, IStorageSync } from "./IStorage";
4
+ import { StorageSync } from "./StorageObservable";
5
+ import { TransactionStorage } from "./TransactionStorage";
6
+ export declare class DiskCollection<T> implements IStorageSync<T> {
7
+ private collectionName;
8
+ private writeDelay?;
9
+ constructor(collectionName: string, writeDelay?: number | undefined);
10
+ transactionStorage: TransactionStorage | undefined;
11
+ initStorage(): Promise<IStorage<T>>;
12
+ baseStorage: Promise<IStorage<T>>;
13
+ private synced;
14
+ get(key: string): T | undefined;
15
+ getPromise(key: string): Promise<T | undefined>;
16
+ set(key: string, value: T): void;
17
+ remove(key: string): void;
18
+ getKeys(): string[];
19
+ getKeysPromise(): Promise<string[]>;
20
+ getEntries(): [string, T][];
21
+ getValues(): T[];
22
+ getValuesPromise(): Promise<T[]>;
23
+ getInfo(key: string): {
24
+ size: number;
25
+ lastModified: number;
26
+ } | undefined;
27
+ reset(): Promise<void>;
28
+ }
29
+ export declare class DiskCollectionBrowser<T> implements IStorageSync<T> {
30
+ private collectionName;
31
+ private writeDelay?;
32
+ constructor(collectionName: string, writeDelay?: number | undefined);
33
+ transactionStorage: TransactionStorage | undefined;
34
+ initStorage(): Promise<IStorage<T>>;
35
+ baseStorage: Promise<IStorage<T>>;
36
+ private synced;
37
+ get(key: string): T | undefined;
38
+ getPromise(key: string): Promise<T | undefined>;
39
+ set(key: string, value: T): void;
40
+ remove(key: string): void;
41
+ getKeys(): string[];
42
+ getKeysPromise(): Promise<string[]>;
43
+ getEntries(): [string, T][];
44
+ getValues(): T[];
45
+ getValuesPromise(): Promise<T[]>;
46
+ getInfo(key: string): {
47
+ size: number;
48
+ lastModified: number;
49
+ } | undefined;
50
+ reset(): Promise<void>;
51
+ }
52
+ export declare class DiskCollectionPromise<T> implements IStorage<T> {
53
+ private collectionName;
54
+ private writeDelay?;
55
+ constructor(collectionName: string, writeDelay?: number | undefined);
56
+ initStorage(): Promise<IStorage<T>>;
57
+ private synced;
58
+ get(key: string): Promise<T | undefined>;
59
+ set(key: string, value: T): Promise<void>;
60
+ remove(key: string): Promise<void>;
61
+ getKeys(): Promise<string[]>;
62
+ getInfo(key: string): Promise<{
63
+ size: number;
64
+ lastModified: number;
65
+ } | undefined>;
66
+ reset(): Promise<void>;
67
+ }
68
+ export declare class DiskCollectionRaw implements IStorage<Buffer> {
69
+ private collectionName;
70
+ constructor(collectionName: string);
71
+ initStorage(): Promise<IStorage<Buffer>>;
72
+ private synced;
73
+ get(key: string): Promise<Buffer | undefined>;
74
+ set(key: string, value: Buffer): Promise<void>;
75
+ remove(key: string): Promise<void>;
76
+ getKeys(): Promise<string[]>;
77
+ getInfo(key: string): Promise<{
78
+ size: number;
79
+ lastModified: number;
80
+ } | undefined>;
81
+ reset(): Promise<void>;
82
+ }
83
+ export declare class DiskCollectionRawBrowser {
84
+ private collectionName;
85
+ constructor(collectionName: string);
86
+ initStorage(): Promise<IStorage<Buffer>>;
87
+ private synced;
88
+ get(key: string): Buffer | undefined;
89
+ getPromise(key: string): Promise<Buffer | undefined>;
90
+ set(key: string, value: Buffer): void;
91
+ getKeys(): Promise<string[]>;
92
+ getInfo(key: string): Promise<{
93
+ size: number;
94
+ lastModified: number;
95
+ } | undefined>;
96
+ reset(): Promise<void>;
97
+ }
98
+ export declare function newFileStorageBufferSyncer(folder?: string): StorageSync<Buffer>;
99
+ export declare function newFileStorageJSONSyncer<T>(folder?: string): StorageSync<T>;
@@ -0,0 +1,71 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { IStorageRaw } from "./IStorage";
4
+ type FileWrapper = {
5
+ getFile(): Promise<{
6
+ size: number;
7
+ lastModified: number;
8
+ arrayBuffer(): Promise<ArrayBuffer>;
9
+ }>;
10
+ createWritable(config?: {
11
+ keepExistingData?: boolean;
12
+ }): Promise<{
13
+ seek(offset: number): Promise<void>;
14
+ write(value: Buffer): Promise<void>;
15
+ close(): Promise<void>;
16
+ }>;
17
+ };
18
+ type DirectoryWrapper = {
19
+ removeEntry(key: string, options?: {
20
+ recursive?: boolean;
21
+ }): Promise<void>;
22
+ getFileHandle(key: string, options?: {
23
+ create?: boolean;
24
+ }): Promise<FileWrapper>;
25
+ getDirectoryHandle(key: string, options?: {
26
+ create?: boolean;
27
+ }): Promise<DirectoryWrapper>;
28
+ [Symbol.asyncIterator](): AsyncIterableIterator<[
29
+ string,
30
+ {
31
+ kind: "file";
32
+ name: string;
33
+ getFile(): Promise<FileWrapper>;
34
+ } | {
35
+ kind: "directory";
36
+ name: string;
37
+ getDirectoryHandle(key: string, options?: {
38
+ create?: boolean;
39
+ }): Promise<DirectoryWrapper>;
40
+ }
41
+ ]>;
42
+ };
43
+ export declare const getDirectoryHandle: {
44
+ (): Promise<DirectoryWrapper>;
45
+ reset(): void;
46
+ set(newValue: Promise<DirectoryWrapper>): void;
47
+ };
48
+ export declare const getFileStorageNested: {
49
+ (key: string): Promise<FileStorage>;
50
+ clear(key: string): void;
51
+ clearAll(): void;
52
+ forceSet(key: string, value: Promise<FileStorage>): void;
53
+ getAllKeys(): string[];
54
+ get(key: string): Promise<FileStorage> | undefined;
55
+ };
56
+ export declare const getFileStorage: {
57
+ (): Promise<FileStorage>;
58
+ reset(): void;
59
+ set(newValue: Promise<FileStorage>): void;
60
+ };
61
+ export declare function resetStorageLocation(): void;
62
+ export type NestedFileStorage = {
63
+ hasKey(key: string): Promise<boolean>;
64
+ getStorage(key: string): Promise<FileStorage>;
65
+ removeStorage(key: string): Promise<void>;
66
+ getKeys(): Promise<string[]>;
67
+ };
68
+ export type FileStorage = IStorageRaw & {
69
+ folder: NestedFileStorage;
70
+ };
71
+ export {};
@@ -0,0 +1,38 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ export type IStorageSync<T> = {
4
+ get(key: string): T | undefined;
5
+ set(key: string, value: T): void;
6
+ remove(key: string): void;
7
+ getKeys(): string[];
8
+ getValues(): T[];
9
+ getEntries(): [string, T][];
10
+ getInfo(key: string): {
11
+ size: number;
12
+ lastModified: number;
13
+ } | undefined;
14
+ reset(): Promise<void>;
15
+ };
16
+ export type IStorage<T> = {
17
+ get(key: string): Promise<T | undefined>;
18
+ set(key: string, value: T): Promise<void>;
19
+ remove(key: string): Promise<void>;
20
+ getKeys(): Promise<string[]>;
21
+ getInfo(key: string): Promise<undefined | {
22
+ size: number;
23
+ lastModified: number;
24
+ }>;
25
+ reset(): Promise<void>;
26
+ };
27
+ export type IStorageRaw = {
28
+ get(key: string): Promise<Buffer | undefined>;
29
+ append(key: string, value: Buffer): Promise<void>;
30
+ set(key: string, value: Buffer): Promise<void>;
31
+ remove(key: string): Promise<void>;
32
+ getKeys(): Promise<string[]>;
33
+ getInfo(key: string): Promise<undefined | {
34
+ size: number;
35
+ lastModified: number;
36
+ }>;
37
+ reset(): Promise<void>;
38
+ };
@@ -0,0 +1,6 @@
1
+ import { FileStorage } from "./FileFolderAPI";
2
+ export declare const getFileStorageIndexDB: {
3
+ (): Promise<FileStorage>;
4
+ reset(): void;
5
+ set(newValue: Promise<FileStorage>): void;
6
+ };
@@ -0,0 +1,16 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { IStorage } from "./IStorage";
4
+ export declare class JSONStorage<T> implements IStorage<T> {
5
+ private storage;
6
+ constructor(storage: IStorage<Buffer>);
7
+ get(key: string): Promise<T | undefined>;
8
+ set(key: string, value: T): Promise<void>;
9
+ remove(key: string): Promise<void>;
10
+ getKeys(): Promise<string[]>;
11
+ getInfo(key: string): Promise<{
12
+ size: number;
13
+ lastModified: number;
14
+ } | undefined>;
15
+ reset(): Promise<void>;
16
+ }
@@ -0,0 +1,6 @@
1
+ import preact from "preact";
2
+ export declare function setPending(group: string, message: string): void;
3
+ export declare function hasPending(): boolean;
4
+ export declare class PendingDisplay extends preact.Component {
5
+ render(): preact.JSX.Element;
6
+ }
@@ -0,0 +1,18 @@
1
+ import { IStorage } from "./IStorage";
2
+ export declare class PendingStorage<T> implements IStorage<T> {
3
+ private pendingGroup;
4
+ private storage;
5
+ pending: Map<string, number>;
6
+ constructor(pendingGroup: string, storage: IStorage<T>);
7
+ get(key: string): Promise<T | undefined>;
8
+ set(key: string, value: T): Promise<void>;
9
+ remove(key: string): Promise<void>;
10
+ getKeys(): Promise<string[]>;
11
+ getInfo(key: string): Promise<{
12
+ size: number;
13
+ lastModified: number;
14
+ } | undefined>;
15
+ private watchPending;
16
+ private updatePending;
17
+ reset(): Promise<void>;
18
+ }
@@ -0,0 +1,23 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { IStorageRaw } from "./IStorage";
4
+ export declare class PrivateFileSystemStorage implements IStorageRaw {
5
+ private path;
6
+ private rootHandle;
7
+ constructor(path: string);
8
+ private ensureInitialized;
9
+ private directoryExists;
10
+ private getDirectoryHandle;
11
+ private getFileHandle;
12
+ private fileExists;
13
+ get(key: string): Promise<Buffer | undefined>;
14
+ set(key: string, value: Buffer): Promise<void>;
15
+ append(key: string, value: Buffer): Promise<void>;
16
+ remove(key: string): Promise<void>;
17
+ getKeys(): Promise<string[]>;
18
+ getInfo(key: string): Promise<undefined | {
19
+ size: number;
20
+ lastModified: number;
21
+ }>;
22
+ reset(): Promise<void>;
23
+ }
@@ -0,0 +1,32 @@
1
+ import { IStorage, IStorageSync } from "./IStorage";
2
+ export declare class StorageSync<T> implements IStorageSync<T> {
3
+ storage: IStorage<T>;
4
+ cached: import("mobx").ObservableMap<string, T | undefined>;
5
+ infoCached: import("mobx").ObservableMap<string, {
6
+ size: number;
7
+ lastModified: number;
8
+ } | undefined>;
9
+ keys: Set<string>;
10
+ synced: {
11
+ keySeqNum: number;
12
+ };
13
+ constructor(storage: IStorage<T>);
14
+ get(key: string): T | undefined;
15
+ set(key: string, value: T): void;
16
+ remove(key: string): void;
17
+ private loadedKeys;
18
+ getKeys(): string[];
19
+ getInfo(key: string): {
20
+ size: number;
21
+ lastModified: number;
22
+ } | undefined;
23
+ getValues(): T[];
24
+ getEntries(): [string, T][];
25
+ getPromise(key: string): Promise<T | undefined>;
26
+ private pendingGetKeys;
27
+ getKeysPromise(): Promise<string[]>;
28
+ reload(): void;
29
+ reloadKeys(): void;
30
+ reloadKey(key: string): void;
31
+ reset(): Promise<void>;
32
+ }
@@ -0,0 +1,46 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { IStorage, IStorageRaw } from "./IStorage";
4
+ interface TransactionEntry {
5
+ key: string;
6
+ value: Buffer | undefined;
7
+ isZipped: boolean;
8
+ time: number;
9
+ }
10
+ export declare class TransactionStorage implements IStorage<Buffer> {
11
+ private rawStorage;
12
+ private debugName;
13
+ private writeDelay;
14
+ cache: Map<string, TransactionEntry>;
15
+ private currentChunk;
16
+ private currentChunkSize;
17
+ private entryCount;
18
+ private static allStorage;
19
+ constructor(rawStorage: IStorageRaw, debugName: string, writeDelay?: number);
20
+ static compressAll(): Promise<void>;
21
+ private init;
22
+ private getChunk;
23
+ get(key: string): Promise<Buffer | undefined>;
24
+ set(key: string, value: Buffer): Promise<void>;
25
+ remove(key: string): Promise<void>;
26
+ getInfo(key: string): Promise<{
27
+ size: number;
28
+ lastModified: number;
29
+ } | undefined>;
30
+ private pendingAppends;
31
+ private extraAppends;
32
+ private pendingWrite;
33
+ pushAppend(entry: TransactionEntry): Promise<void>;
34
+ private updatePendingAppends;
35
+ getKeys(): Promise<string[]>;
36
+ private loadAllTransactions;
37
+ private loadTransactionFile;
38
+ private readTransactionEntry;
39
+ private serializeTransactionEntry;
40
+ private getHeader;
41
+ private chunkBuffers;
42
+ private compressing;
43
+ private compressTransactionLog;
44
+ reset(): Promise<void>;
45
+ }
46
+ export {};