sliftutils 1.2.20 → 1.2.21

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.
package/index.d.ts CHANGED
@@ -859,6 +859,21 @@ declare module "sliftutils/storage/DiskCollection" {
859
859
  } | undefined>;
860
860
  reset(): Promise<void>;
861
861
  }
862
+ export declare class DiskCollectionRawSynced {
863
+ private collectionName;
864
+ constructor(collectionName: string);
865
+ initStorage(): Promise<IStorage<Buffer>>;
866
+ private synced;
867
+ get(key: string): Buffer | undefined;
868
+ getPromise(key: string): Promise<Buffer | undefined>;
869
+ set(key: string, value: Buffer): void;
870
+ getKeys(): Promise<string[]>;
871
+ getInfo(key: string): Promise<{
872
+ size: number;
873
+ lastModified: number;
874
+ } | undefined>;
875
+ reset(): Promise<void>;
876
+ }
862
877
  export declare class DiskCollectionRawBrowser {
863
878
  private collectionName;
864
879
  constructor(collectionName: string);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "1.2.20",
3
+ "version": "1.2.21",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -67,6 +67,21 @@ export declare class DiskCollectionRaw implements IStorage<Buffer> {
67
67
  } | undefined>;
68
68
  reset(): Promise<void>;
69
69
  }
70
+ export declare class DiskCollectionRawSynced {
71
+ private collectionName;
72
+ constructor(collectionName: string);
73
+ initStorage(): Promise<IStorage<Buffer>>;
74
+ private synced;
75
+ get(key: string): Buffer | undefined;
76
+ getPromise(key: string): Promise<Buffer | undefined>;
77
+ set(key: string, value: Buffer): void;
78
+ getKeys(): Promise<string[]>;
79
+ getInfo(key: string): Promise<{
80
+ size: number;
81
+ lastModified: number;
82
+ } | undefined>;
83
+ reset(): Promise<void>;
84
+ }
70
85
  export declare class DiskCollectionRawBrowser {
71
86
  private collectionName;
72
87
  constructor(collectionName: string);
@@ -174,6 +174,42 @@ export class DiskCollectionRaw implements IStorage<Buffer> {
174
174
  }
175
175
  }
176
176
 
177
+ export class DiskCollectionRawSynced {
178
+ constructor(private collectionName: string) { }
179
+ async initStorage(): Promise<IStorage<Buffer>> {
180
+ let fileStorage = await getFileStorage();
181
+ let collections = await fileStorage.folder.getStorage("collections");
182
+ let baseStorage = await collections.folder.getStorage(this.collectionName);
183
+ return baseStorage;
184
+ }
185
+ private synced = new StorageSync(
186
+ new PendingStorage(`Collection (${this.collectionName})`,
187
+ new DelayedStorage(this.initStorage())
188
+ )
189
+ );
190
+
191
+ public get(key: string): Buffer | undefined {
192
+ return this.synced.get(key);
193
+ }
194
+
195
+ public async getPromise(key: string): Promise<Buffer | undefined> {
196
+ return await this.synced.get(key);
197
+ }
198
+ public set(key: string, value: Buffer) {
199
+ this.synced.set(key, value);
200
+ }
201
+ public async getKeys(): Promise<string[]> {
202
+ return await this.synced.getKeys();
203
+ }
204
+ public async getInfo(key: string) {
205
+ return await this.synced.getInfo(key);
206
+ }
207
+
208
+ public async reset() {
209
+ await this.synced.reset();
210
+ }
211
+ }
212
+
177
213
  export class DiskCollectionRawBrowser {
178
214
  constructor(private collectionName: string) { }
179
215
  async initStorage(): Promise<IStorage<Buffer>> {