@fireproof/vendor 1.0.3 → 1.0.4
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/package.json +1 -1
- package/src/@ipld/car/dist/src/promise-fs-opts.d.ts +30 -0
- package/src/@ipld/car/dist/src/promise-fs-opts.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/reader.d.ts +6 -2
- package/src/@ipld/car/dist/src/reader.d.ts.map +1 -1
- package/src/@ipld/car/dist/src/writer.d.ts +1 -2
- package/src/@ipld/car/dist/src/writer.d.ts.map +1 -1
- package/src/@ipld/car/src/promise-fs-opts.js +42 -0
- package/src/@ipld/car/src/reader.js +1 -21
- package/src/@ipld/car/src/writer.js +2 -6
package/package.json
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* @description This function is needed not to initialize the `fs.read` on load time. To run in cf workers without polyfill.
|
|
4
|
+
* @param {number} fd
|
|
5
|
+
* @param {Uint8Array} buffer
|
|
6
|
+
* @param {number} offset
|
|
7
|
+
* @param {number} length
|
|
8
|
+
* @param {number} position
|
|
9
|
+
* @returns {Promise<{ bytesRead: number, buffer: Uint8Array }>}
|
|
10
|
+
*/
|
|
11
|
+
export function fsread(fd: number, buffer: Uint8Array, offset: number, length: number, position: number): Promise<{
|
|
12
|
+
bytesRead: number;
|
|
13
|
+
buffer: Uint8Array;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* @description This function is needed not to initialize the `fs.write` on load time. To run in cf workers without polyfill.
|
|
17
|
+
* @param {number} fd
|
|
18
|
+
* @param {Uint8Array} buffer
|
|
19
|
+
* @param {number} offset
|
|
20
|
+
* @param {number} length
|
|
21
|
+
* @param {number} position
|
|
22
|
+
* @returns {Promise<{ bytesRead: number, buffer: Uint8Array }>}
|
|
23
|
+
*/
|
|
24
|
+
export function fswrite(fd: number, buffer: Uint8Array, offset: number, length: number, position: number): Promise<{
|
|
25
|
+
bytesRead: number;
|
|
26
|
+
buffer: Uint8Array;
|
|
27
|
+
}>;
|
|
28
|
+
export { fs };
|
|
29
|
+
import fs from 'fs';
|
|
30
|
+
//# sourceMappingURL=promise-fs-opts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-fs-opts.d.ts","sourceRoot":"","sources":["../../src/promise-fs-opts.js"],"names":[],"mappings":";AAUA;;;;;;;;GAQG;AACH,2BAPW,MAAM,UACN,UAAU,UACV,MAAM,UACN,MAAM,YACN,MAAM,GACJ,QAAQ;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,CAK9D;AAOD;;;;;;;;GAQG;AACH,4BAPW,MAAM,UACN,UAAU,UACV,MAAM,UACN,MAAM,YACN,MAAM,GACJ,QAAQ;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,CAK9D;;eAzCc,IAAI"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('./api').Block} Block
|
|
3
|
+
* @typedef {import('./api').BlockIndex} BlockIndex
|
|
4
|
+
* @typedef {import('./api').CarReader} CarReaderIface
|
|
5
|
+
*/
|
|
2
6
|
/**
|
|
3
7
|
* @class
|
|
4
8
|
* @implements {CarReaderIface}
|
|
@@ -31,5 +35,5 @@ export type Block = import('./api').Block;
|
|
|
31
35
|
export type BlockIndex = import('./api').BlockIndex;
|
|
32
36
|
export type CarReaderIface = import('./api').CarReader;
|
|
33
37
|
import { CarReader as BrowserCarReader } from './reader-browser.js';
|
|
34
|
-
import fs from 'fs';
|
|
38
|
+
import { fs } from './promise-fs-opts.js';
|
|
35
39
|
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/reader.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/reader.js"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH;;;GAGG;AACH;IACE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,mBARW,GAAG,QAAQ,CAAC,UAAU,GAAG,MAAM,cAG/B,UAAU,GAGR,QAAQ,KAAK,CAAC,CAiB1B;CACF;AAED,8BAA4B;oBAhDf,OAAO,OAAO,EAAE,KAAK;yBACrB,OAAO,OAAO,EAAE,UAAU;6BAC1B,OAAO,OAAO,EAAE,SAAS;8CALQ,qBAAqB;mBADxC,sBAAsB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
/**
|
|
3
2
|
* @typedef {import('multiformats/cid').CID} CID
|
|
4
3
|
* @typedef {import('./api').BlockWriter} BlockWriter
|
|
@@ -41,5 +40,5 @@ export const __browser: false;
|
|
|
41
40
|
export type CID = import('multiformats/cid').CID;
|
|
42
41
|
export type BlockWriter = import('./api').BlockWriter;
|
|
43
42
|
import { CarWriter as BrowserCarWriter } from './writer-browser.js';
|
|
44
|
-
import fs from 'fs';
|
|
43
|
+
import { fs } from './promise-fs-opts.js';
|
|
45
44
|
//# sourceMappingURL=writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/writer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/writer.js"],"names":[],"mappings":"AAKA;;;GAGG;AAEH;;;GAGG;AACH;IACE;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,6BATW,GAAG,QAAQ,CAAC,UAAU,GAAG,MAAM,SAG/B,GAAG,EAAE,GAIH,QAAQ,IAAI,CAAC,CAoCzB;CACF;AAED,8BAA4B;kBAzEf,OAAO,kBAAkB,EAAE,GAAG;0BAC9B,OAAO,OAAO,EAAE,WAAW;8CAJM,qBAAqB;mBAD/B,sBAAsB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import { promisify } from 'util'
|
|
3
|
+
|
|
4
|
+
export { fs }
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description not happy with typing here, but it's needed for the `promisify(fs.read)` function.
|
|
8
|
+
* @type {any}
|
|
9
|
+
*/
|
|
10
|
+
let _fsReadFn
|
|
11
|
+
/**
|
|
12
|
+
* @description This function is needed not to initialize the `fs.read` on load time. To run in cf workers without polyfill.
|
|
13
|
+
* @param {number} fd
|
|
14
|
+
* @param {Uint8Array} buffer
|
|
15
|
+
* @param {number} offset
|
|
16
|
+
* @param {number} length
|
|
17
|
+
* @param {number} position
|
|
18
|
+
* @returns {Promise<{ bytesRead: number, buffer: Uint8Array }>}
|
|
19
|
+
*/
|
|
20
|
+
export function fsread (fd, buffer, offset, length, position) {
|
|
21
|
+
_fsReadFn = _fsReadFn || promisify(fs.read)
|
|
22
|
+
return _fsReadFn(fd, buffer, offset, length, position)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @description not happy with typing here, but it's needed for the `promisify(fs.write)` function.
|
|
27
|
+
* @type {any}
|
|
28
|
+
*/
|
|
29
|
+
let _fsWriteFn
|
|
30
|
+
/**
|
|
31
|
+
* @description This function is needed not to initialize the `fs.write` on load time. To run in cf workers without polyfill.
|
|
32
|
+
* @param {number} fd
|
|
33
|
+
* @param {Uint8Array} buffer
|
|
34
|
+
* @param {number} offset
|
|
35
|
+
* @param {number} length
|
|
36
|
+
* @param {number} position
|
|
37
|
+
* @returns {Promise<{ bytesRead: number, buffer: Uint8Array }>}
|
|
38
|
+
*/
|
|
39
|
+
export function fswrite (fd, buffer, offset, length, position) {
|
|
40
|
+
_fsWriteFn = _fsWriteFn || promisify(fs.write)
|
|
41
|
+
return _fsWriteFn(fd, buffer, offset, length, position)
|
|
42
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import { promisify } from 'util'
|
|
1
|
+
import { fsread, fs } from './promise-fs-opts.js'
|
|
3
2
|
import { CarReader as BrowserCarReader } from './reader-browser.js'
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -8,25 +7,6 @@ import { CarReader as BrowserCarReader } from './reader-browser.js'
|
|
|
8
7
|
* @typedef {import('./api').CarReader} CarReaderIface
|
|
9
8
|
*/
|
|
10
9
|
|
|
11
|
-
/**
|
|
12
|
-
* @description not happy with typing here, but it's needed for the `promisify(fs.read)` function.
|
|
13
|
-
* @type {any}
|
|
14
|
-
*/
|
|
15
|
-
let _fsReadFn
|
|
16
|
-
/**
|
|
17
|
-
* @description This function is needed not to initialize the `fs.read` on load time. To run in cf workers without polyfill.
|
|
18
|
-
* @param {number} fd
|
|
19
|
-
* @param {Uint8Array} buffer
|
|
20
|
-
* @param {number} offset
|
|
21
|
-
* @param {number} length
|
|
22
|
-
* @param {number} position
|
|
23
|
-
* @returns {Promise<{ bytesRead: number, buffer: Uint8Array }>}
|
|
24
|
-
*/
|
|
25
|
-
function fsread (fd, buffer, offset, length, position) {
|
|
26
|
-
_fsReadFn = _fsReadFn || promisify(fs.read)
|
|
27
|
-
return _fsReadFn(fd, buffer, offset, length, position)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
10
|
/**
|
|
31
11
|
* @class
|
|
32
12
|
* @implements {CarReaderIface}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import { promisify } from 'util'
|
|
3
1
|
import { readHeader, chunkReader } from './decoder.js'
|
|
4
2
|
import { createHeader } from './encoder.js'
|
|
3
|
+
import { fsread, fswrite, fs } from './promise-fs-opts.js'
|
|
5
4
|
import { CarWriter as BrowserCarWriter } from './writer-browser.js'
|
|
6
5
|
|
|
7
|
-
const fsread = promisify(fs.read)
|
|
8
|
-
const fswrite = promisify(fs.write)
|
|
9
|
-
|
|
10
6
|
/**
|
|
11
7
|
* @typedef {import('multiformats/cid').CID} CID
|
|
12
8
|
* @typedef {import('./api').BlockWriter} BlockWriter
|
|
@@ -81,4 +77,4 @@ export class CarWriter extends BrowserCarWriter {
|
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
export const __browser =
|
|
80
|
+
export const __browser = !fs
|