@atlaspack/cache 2.12.1-dev.3502 → 2.12.1-dev.3565

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.
@@ -106,8 +106,8 @@ class LMDBLiteCache {
106
106
  dir: this.dir
107
107
  };
108
108
  }
109
- static deserialize(opts) {
110
- return new LMDBLiteCache(opts.dir);
109
+ static deserialize(cache) {
110
+ return new LMDBLiteCache(cache.dir);
111
111
  }
112
112
  has(key) {
113
113
  return Promise.resolve(this.store.get(key) != null);
@@ -128,12 +128,10 @@ class LMDBLiteCache {
128
128
  setStream(key, stream) {
129
129
  return pipeline(stream, this.fs.createWriteStream(_path().default.join(this.dir, key)));
130
130
  }
131
- getBlob(key) {
132
- try {
133
- return Promise.resolve(this.getBlobSync(key));
134
- } catch (err) {
135
- return Promise.reject(err);
136
- }
131
+
132
+ // eslint-disable-next-line require-await
133
+ async getBlob(key) {
134
+ return this.getBlobSync(key);
137
135
  }
138
136
  getBlobSync(key) {
139
137
  const buffer = this.store.get(key);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaspack/cache",
3
3
  "description": "Interface for defining caches and file-system, IDB and LMDB implementations.",
4
- "version": "2.12.1-dev.3502+c2daeab5a",
4
+ "version": "2.12.1-dev.3565+b31bc6b33",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -22,11 +22,11 @@
22
22
  "check-ts": "tsc --noEmit index.d.ts"
23
23
  },
24
24
  "dependencies": {
25
- "@atlaspack/build-cache": "2.12.1-dev.3502+c2daeab5a",
26
- "@atlaspack/fs": "2.12.1-dev.3502+c2daeab5a",
27
- "@atlaspack/logger": "2.12.1-dev.3502+c2daeab5a",
28
- "@atlaspack/rust": "2.12.1-dev.3502+c2daeab5a",
29
- "@atlaspack/utils": "2.12.1-dev.3502+c2daeab5a",
25
+ "@atlaspack/build-cache": "2.12.1-dev.3565+b31bc6b33",
26
+ "@atlaspack/fs": "2.12.1-dev.3565+b31bc6b33",
27
+ "@atlaspack/logger": "2.12.1-dev.3565+b31bc6b33",
28
+ "@atlaspack/rust": "2.12.1-dev.3565+b31bc6b33",
29
+ "@atlaspack/utils": "2.12.1-dev.3565+b31bc6b33",
30
30
  "lmdb": "2.8.5"
31
31
  },
32
32
  "devDependencies": {
@@ -36,5 +36,5 @@
36
36
  "./src/IDBCache.js": "./src/IDBCache.browser.js",
37
37
  "./src/LMDBCache.js": false
38
38
  },
39
- "gitHead": "c2daeab5a12461903159dec34df5671eaaa9b749"
39
+ "gitHead": "b31bc6b33de40c158b9f4d8ff177238be0de409d"
40
40
  }
@@ -72,6 +72,10 @@ const pipeline: (Readable, Writable) => Promise<void> = promisify(
72
72
  stream.pipeline,
73
73
  );
74
74
 
75
+ export type SerLMDBLiteCache = {|
76
+ dir: FilePath,
77
+ |};
78
+
75
79
  export class LMDBLiteCache implements Cache {
76
80
  fs: NodeFS;
77
81
  dir: FilePath;
@@ -101,14 +105,14 @@ export class LMDBLiteCache implements Cache {
101
105
  return Promise.resolve();
102
106
  }
103
107
 
104
- serialize(): {|dir: FilePath|} {
108
+ serialize(): SerLMDBLiteCache {
105
109
  return {
106
110
  dir: this.dir,
107
111
  };
108
112
  }
109
113
 
110
- static deserialize(opts: {|dir: FilePath|}): LMDBLiteCache {
111
- return new LMDBLiteCache(opts.dir);
114
+ static deserialize(cache: SerLMDBLiteCache): LMDBLiteCache {
115
+ return new LMDBLiteCache(cache.dir);
112
116
  }
113
117
 
114
118
  has(key: string): Promise<boolean> {
@@ -139,12 +143,9 @@ export class LMDBLiteCache implements Cache {
139
143
  );
140
144
  }
141
145
 
142
- getBlob(key: string): Promise<Buffer> {
143
- try {
144
- return Promise.resolve(this.getBlobSync(key));
145
- } catch (err) {
146
- return Promise.reject(err);
147
- }
146
+ // eslint-disable-next-line require-await
147
+ async getBlob(key: string): Promise<Buffer> {
148
+ return this.getBlobSync(key);
148
149
  }
149
150
 
150
151
  getBlobSync(key: string): Buffer {