@zenfs/core 0.3.5 → 0.4.1
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/dist/FileIndex.d.ts +4 -0
- package/dist/FileIndex.js +3 -3
- package/dist/backends/AsyncMirror.d.ts +3 -5
- package/dist/backends/AsyncMirror.js +7 -6
- package/dist/backends/AsyncStore.d.ts +9 -4
- package/dist/backends/AsyncStore.js +7 -2
- package/dist/backends/Locked.d.ts +8 -8
- package/dist/backends/Locked.js +2 -1
- package/dist/backends/Overlay.d.ts +13 -1
- package/dist/backends/Overlay.js +16 -16
- package/dist/backends/SyncStore.d.ts +8 -5
- package/dist/backends/SyncStore.js +9 -5
- package/dist/backends/backend.js +8 -8
- package/dist/browser.min.js +4 -5
- package/dist/browser.min.js.map +4 -4
- package/dist/config.d.ts +23 -0
- package/dist/config.js +36 -0
- package/dist/cred.d.ts +1 -1
- package/dist/cred.js +1 -1
- package/dist/emulation/callbacks.d.ts +1 -1
- package/dist/emulation/callbacks.js +1 -1
- package/dist/emulation/constants.d.ts +48 -42
- package/dist/emulation/constants.js +68 -59
- package/dist/emulation/dir.d.ts +2 -2
- package/dist/emulation/promises.d.ts +1 -1
- package/dist/emulation/promises.js +6 -6
- package/dist/emulation/sync.d.ts +1 -1
- package/dist/emulation/sync.js +7 -7
- package/dist/file.d.ts +26 -12
- package/dist/file.js +68 -29
- package/dist/filesystem.d.ts +3 -3
- package/dist/index.d.ts +7 -29
- package/dist/index.js +7 -44
- package/dist/inode.d.ts +21 -15
- package/dist/inode.js +52 -40
- package/dist/mutex.d.ts +1 -2
- package/dist/mutex.js +1 -1
- package/dist/stats.d.ts +70 -18
- package/dist/stats.js +12 -18
- package/dist/utils.d.ts +3 -8
- package/dist/utils.js +60 -39
- package/license.md +3 -80
- package/package.json +71 -63
- package/readme.md +19 -11
- package/scripts/make-index.js +100 -0
- package/dist/backends/index.d.ts +0 -10
- package/dist/backends/index.js +0 -12
package/dist/stats.d.ts
CHANGED
|
@@ -10,14 +10,58 @@ export declare enum FileType {
|
|
|
10
10
|
SYMLINK
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export interface StatsLike {
|
|
16
|
+
/**
|
|
17
|
+
* Size of the item in bytes.
|
|
18
|
+
* For directories/symlinks, this is normally the size of the struct that represents the item.
|
|
19
|
+
*/
|
|
20
|
+
size: number | bigint;
|
|
21
|
+
/**
|
|
22
|
+
* Unix-style file mode (e.g. 0o644) that includes the item type
|
|
23
|
+
* Type of the item can be FILE, DIRECTORY, SYMLINK, or SOCKET
|
|
24
|
+
*/
|
|
25
|
+
mode: number | bigint;
|
|
26
|
+
/**
|
|
27
|
+
* time of last access, in milliseconds since epoch
|
|
28
|
+
*/
|
|
29
|
+
atimeMs: number | bigint;
|
|
30
|
+
/**
|
|
31
|
+
* time of last modification, in milliseconds since epoch
|
|
32
|
+
*/
|
|
33
|
+
mtimeMs: number | bigint;
|
|
34
|
+
/**
|
|
35
|
+
* time of last time file status was changed, in milliseconds since epoch
|
|
36
|
+
*/
|
|
37
|
+
ctimeMs: number | bigint;
|
|
38
|
+
/**
|
|
39
|
+
* time of file creation, in milliseconds since epoch
|
|
40
|
+
*/
|
|
41
|
+
birthtimeMs: number | bigint;
|
|
42
|
+
/**
|
|
43
|
+
* the id of the user that owns the file
|
|
44
|
+
*/
|
|
45
|
+
uid: number | bigint;
|
|
46
|
+
/**
|
|
47
|
+
* the id of the group that owns the file
|
|
48
|
+
*/
|
|
49
|
+
gid: number | bigint;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Provides information about a particular entry in the file system.
|
|
53
|
+
* Common code used by both Stats and BigIntStats.
|
|
14
54
|
*/
|
|
15
|
-
export declare abstract class StatsCommon<T extends number | bigint> implements Node.StatsBase<T
|
|
55
|
+
export declare abstract class StatsCommon<T extends number | bigint> implements Node.StatsBase<T>, StatsLike {
|
|
16
56
|
protected abstract _isBigint: boolean;
|
|
17
57
|
protected get _typename(): string;
|
|
18
58
|
protected get _typename_inverse(): string;
|
|
19
59
|
protected _convert(arg: number | bigint | string | boolean): T;
|
|
20
60
|
blocks: T;
|
|
61
|
+
/**
|
|
62
|
+
* Unix-style file mode (e.g. 0o644) that includes the type of the item.
|
|
63
|
+
* Type of the item can be FILE, DIRECTORY, SYMLINK, or SOCKET
|
|
64
|
+
*/
|
|
21
65
|
mode: T;
|
|
22
66
|
/**
|
|
23
67
|
* ID of device containing file
|
|
@@ -51,33 +95,39 @@ export declare abstract class StatsCommon<T extends number | bigint> implements
|
|
|
51
95
|
* Some file systems stash data on stats objects.
|
|
52
96
|
*/
|
|
53
97
|
fileData?: Uint8Array;
|
|
98
|
+
/**
|
|
99
|
+
* time of last access, in milliseconds since epoch
|
|
100
|
+
*/
|
|
54
101
|
atimeMs: T;
|
|
55
102
|
get atime(): Date;
|
|
56
103
|
set atime(value: Date);
|
|
104
|
+
/**
|
|
105
|
+
* time of last modification, in milliseconds since epoch
|
|
106
|
+
*/
|
|
57
107
|
mtimeMs: T;
|
|
58
108
|
get mtime(): Date;
|
|
59
109
|
set mtime(value: Date);
|
|
110
|
+
/**
|
|
111
|
+
* time of last time file status was changed, in milliseconds since epoch
|
|
112
|
+
*/
|
|
60
113
|
ctimeMs: T;
|
|
61
114
|
get ctime(): Date;
|
|
62
115
|
set ctime(value: Date);
|
|
116
|
+
/**
|
|
117
|
+
* time of file creation, in milliseconds since epoch
|
|
118
|
+
*/
|
|
63
119
|
birthtimeMs: T;
|
|
64
120
|
get birthtime(): Date;
|
|
65
121
|
set birthtime(value: Date);
|
|
122
|
+
/**
|
|
123
|
+
* Size of the item in bytes.
|
|
124
|
+
* For directories/symlinks, this is normally the size of the struct that represents the item.
|
|
125
|
+
*/
|
|
66
126
|
size: T;
|
|
67
127
|
/**
|
|
68
|
-
*
|
|
69
|
-
* @param itemType Type of the item (FILE, DIRECTORY, SYMLINK, or SOCKET)
|
|
70
|
-
* @param size Size of the item in bytes. For directories/symlinks,
|
|
71
|
-
* this is normally the size of the struct that represents the item.
|
|
72
|
-
* @param mode Unix-style file mode (e.g. 0o644)
|
|
73
|
-
* @param atimeMs time of last access, in milliseconds since epoch
|
|
74
|
-
* @param mtimeMs time of last modification, in milliseconds since epoch
|
|
75
|
-
* @param ctimeMs time of last time file status was changed, in milliseconds since epoch
|
|
76
|
-
* @param uid the id of the user that owns the file
|
|
77
|
-
* @param gid the id of the group that owns the file
|
|
78
|
-
* @param birthtimeMs time of file creation, in milliseconds since epoch
|
|
128
|
+
* Creates a new stats instance from a stats-like object. Can be used to copy stats (note)
|
|
79
129
|
*/
|
|
80
|
-
constructor(
|
|
130
|
+
constructor({ atimeMs, mtimeMs, ctimeMs, birthtimeMs, uid, gid, size, mode }?: Partial<StatsLike>);
|
|
81
131
|
/**
|
|
82
132
|
* @returns true if this item is a file.
|
|
83
133
|
*/
|
|
@@ -128,18 +178,19 @@ export declare abstract class StatsCommon<T extends number | bigint> implements
|
|
|
128
178
|
* @see http://nodejs.org/api/fs.html#fs_class_fs_stats
|
|
129
179
|
* @see http://man7.org/linux/man-pages/man2/stat.2.html
|
|
130
180
|
*/
|
|
131
|
-
export declare class Stats extends StatsCommon<number> implements Node.Stats {
|
|
181
|
+
export declare class Stats extends StatsCommon<number> implements Node.Stats, StatsLike {
|
|
132
182
|
protected _isBigint: boolean;
|
|
133
183
|
/**
|
|
134
184
|
* Clones the stats object.
|
|
185
|
+
* @deprecated use `new Stats(stats)`
|
|
135
186
|
*/
|
|
136
|
-
static clone(
|
|
187
|
+
static clone(stats: Stats): Stats;
|
|
137
188
|
}
|
|
138
189
|
/**
|
|
139
190
|
* Stats with bigint
|
|
140
191
|
* @todo Implement with bigint instead of wrapping Stats
|
|
141
192
|
*/
|
|
142
|
-
export declare class BigIntStats extends StatsCommon<bigint> implements Node.BigIntStats {
|
|
193
|
+
export declare class BigIntStats extends StatsCommon<bigint> implements Node.BigIntStats, StatsLike {
|
|
143
194
|
protected _isBigint: boolean;
|
|
144
195
|
atimeNs: bigint;
|
|
145
196
|
mtimeNs: bigint;
|
|
@@ -147,6 +198,7 @@ export declare class BigIntStats extends StatsCommon<bigint> implements Node.Big
|
|
|
147
198
|
birthtimeNs: bigint;
|
|
148
199
|
/**
|
|
149
200
|
* Clone a stats object.
|
|
201
|
+
* @deprecated use `new BigIntStats(stats)`
|
|
150
202
|
*/
|
|
151
|
-
static clone(
|
|
203
|
+
static clone(stats: BigIntStats | Stats): BigIntStats;
|
|
152
204
|
}
|
package/dist/stats.js
CHANGED
|
@@ -10,7 +10,8 @@ export var FileType;
|
|
|
10
10
|
FileType[FileType["SYMLINK"] = S_IFLNK] = "SYMLINK";
|
|
11
11
|
})(FileType = FileType || (FileType = {}));
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Provides information about a particular entry in the file system.
|
|
14
|
+
* Common code used by both Stats and BigIntStats.
|
|
14
15
|
*/
|
|
15
16
|
export class StatsCommon {
|
|
16
17
|
get _typename() {
|
|
@@ -47,19 +48,9 @@ export class StatsCommon {
|
|
|
47
48
|
this.birthtimeMs = this._convert(value.getTime());
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
|
-
*
|
|
51
|
-
* @param itemType Type of the item (FILE, DIRECTORY, SYMLINK, or SOCKET)
|
|
52
|
-
* @param size Size of the item in bytes. For directories/symlinks,
|
|
53
|
-
* this is normally the size of the struct that represents the item.
|
|
54
|
-
* @param mode Unix-style file mode (e.g. 0o644)
|
|
55
|
-
* @param atimeMs time of last access, in milliseconds since epoch
|
|
56
|
-
* @param mtimeMs time of last modification, in milliseconds since epoch
|
|
57
|
-
* @param ctimeMs time of last time file status was changed, in milliseconds since epoch
|
|
58
|
-
* @param uid the id of the user that owns the file
|
|
59
|
-
* @param gid the id of the group that owns the file
|
|
60
|
-
* @param birthtimeMs time of file creation, in milliseconds since epoch
|
|
51
|
+
* Creates a new stats instance from a stats-like object. Can be used to copy stats (note)
|
|
61
52
|
*/
|
|
62
|
-
constructor(
|
|
53
|
+
constructor({ atimeMs, mtimeMs, ctimeMs, birthtimeMs, uid, gid, size, mode } = {}) {
|
|
63
54
|
/**
|
|
64
55
|
* ID of device containing file
|
|
65
56
|
*/
|
|
@@ -93,7 +84,7 @@ export class StatsCommon {
|
|
|
93
84
|
*/
|
|
94
85
|
this.fileData = null;
|
|
95
86
|
const currentTime = Date.now();
|
|
96
|
-
const resolveT = (
|
|
87
|
+
const resolveT = (val, _default) => (typeof val == this._typename ? val : this._convert(typeof val == this._typename_inverse ? val : _default));
|
|
97
88
|
this.atimeMs = resolveT(atimeMs, currentTime);
|
|
98
89
|
this.mtimeMs = resolveT(mtimeMs, currentTime);
|
|
99
90
|
this.ctimeMs = resolveT(ctimeMs, currentTime);
|
|
@@ -101,6 +92,7 @@ export class StatsCommon {
|
|
|
101
92
|
this.uid = resolveT(uid, 0);
|
|
102
93
|
this.gid = resolveT(gid, 0);
|
|
103
94
|
this.size = this._convert(size);
|
|
95
|
+
const itemType = Number(mode) & S_IFMT || FileType.FILE;
|
|
104
96
|
if (mode) {
|
|
105
97
|
this.mode = this._convert(mode);
|
|
106
98
|
}
|
|
@@ -229,9 +221,10 @@ export class Stats extends StatsCommon {
|
|
|
229
221
|
}
|
|
230
222
|
/**
|
|
231
223
|
* Clones the stats object.
|
|
224
|
+
* @deprecated use `new Stats(stats)`
|
|
232
225
|
*/
|
|
233
|
-
static clone(
|
|
234
|
-
return new Stats(
|
|
226
|
+
static clone(stats) {
|
|
227
|
+
return new Stats(stats);
|
|
235
228
|
}
|
|
236
229
|
}
|
|
237
230
|
Stats;
|
|
@@ -246,9 +239,10 @@ export class BigIntStats extends StatsCommon {
|
|
|
246
239
|
}
|
|
247
240
|
/**
|
|
248
241
|
* Clone a stats object.
|
|
242
|
+
* @deprecated use `new BigIntStats(stats)`
|
|
249
243
|
*/
|
|
250
|
-
static clone(
|
|
251
|
-
return new BigIntStats(
|
|
244
|
+
static clone(stats) {
|
|
245
|
+
return new BigIntStats(stats);
|
|
252
246
|
}
|
|
253
247
|
}
|
|
254
248
|
BigIntStats;
|
package/dist/utils.d.ts
CHANGED
|
@@ -7,23 +7,18 @@ declare global {
|
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Synchronous recursive makedir.
|
|
10
|
-
* @
|
|
10
|
+
* @hidden
|
|
11
11
|
*/
|
|
12
12
|
export declare function mkdirpSync(p: string, mode: number, cred: Cred, fs: FileSystem): void;
|
|
13
13
|
/**
|
|
14
14
|
* Calculates levenshtein distance.
|
|
15
|
-
* @
|
|
15
|
+
* @hidden
|
|
16
16
|
*/
|
|
17
17
|
export declare function levenshtein(a: string, b: string): number;
|
|
18
18
|
/** Waits n ms. */
|
|
19
19
|
export declare function wait(ms: number): Promise<void>;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @todo Look at changing resolve value from cbArgs[0] to include other callback arguments?
|
|
23
|
-
*/
|
|
24
|
-
export declare function toPromise(fn: (...fnArgs: unknown[]) => unknown): (...args: unknown[]) => Promise<unknown>;
|
|
25
|
-
/**
|
|
26
|
-
* @internal
|
|
21
|
+
* @hidden
|
|
27
22
|
*/
|
|
28
23
|
export declare const setImmediate: (callback: () => unknown) => void;
|
|
29
24
|
/**
|
package/dist/utils.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { ApiError, ErrorCode } from './ApiError.js';
|
|
2
|
-
import
|
|
2
|
+
import { dirname } from './emulation/path.js';
|
|
3
3
|
/**
|
|
4
4
|
* Synchronous recursive makedir.
|
|
5
|
-
* @
|
|
5
|
+
* @hidden
|
|
6
6
|
*/
|
|
7
7
|
export function mkdirpSync(p, mode, cred, fs) {
|
|
8
8
|
if (!fs.existsSync(p, cred)) {
|
|
9
|
-
mkdirpSync(
|
|
9
|
+
mkdirpSync(dirname(p), mode, cred, fs);
|
|
10
10
|
fs.mkdirSync(p, mode, cred);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
/*
|
|
14
|
-
* Levenshtein distance, from the `js-levenshtein` NPM module.
|
|
15
|
-
* Copied here to avoid complexity of adding another CommonJS module dependency.
|
|
16
|
-
*/
|
|
17
13
|
function _min(d0, d1, d2, bx, ay) {
|
|
18
14
|
return Math.min(d0 + 1, d1 + 1, d2 + 1, bx === ay ? d1 : d1 + 1);
|
|
19
15
|
}
|
|
20
16
|
/**
|
|
21
17
|
* Calculates levenshtein distance.
|
|
22
|
-
* @
|
|
18
|
+
* @hidden
|
|
23
19
|
*/
|
|
24
20
|
export function levenshtein(a, b) {
|
|
25
21
|
if (a === b) {
|
|
@@ -94,26 +90,7 @@ export function wait(ms) {
|
|
|
94
90
|
});
|
|
95
91
|
}
|
|
96
92
|
/**
|
|
97
|
-
*
|
|
98
|
-
* @todo Look at changing resolve value from cbArgs[0] to include other callback arguments?
|
|
99
|
-
*/
|
|
100
|
-
export function toPromise(fn) {
|
|
101
|
-
return function (...args) {
|
|
102
|
-
return new Promise((resolve, reject) => {
|
|
103
|
-
args.push((e, ...cbArgs) => {
|
|
104
|
-
if (e) {
|
|
105
|
-
reject(e);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
resolve(cbArgs[0]);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
fn(...args);
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* @internal
|
|
93
|
+
* @hidden
|
|
117
94
|
*/
|
|
118
95
|
export const setImmediate = typeof globalThis.setImmediate == 'function' ? globalThis.setImmediate : cb => setTimeout(cb, 0);
|
|
119
96
|
/**
|
|
@@ -121,21 +98,45 @@ export const setImmediate = typeof globalThis.setImmediate == 'function' ? globa
|
|
|
121
98
|
* @internal
|
|
122
99
|
*/
|
|
123
100
|
export function encode(input, encoding = 'utf8') {
|
|
101
|
+
if (typeof input != 'string') {
|
|
102
|
+
throw new ApiError(ErrorCode.EINVAL, 'Can not encode a non-string');
|
|
103
|
+
}
|
|
124
104
|
switch (encoding) {
|
|
125
105
|
case 'ascii':
|
|
126
|
-
return new globalThis.TextEncoder().encode(input).map(v => v & 0x7f);
|
|
127
106
|
case 'latin1':
|
|
128
107
|
case 'binary':
|
|
108
|
+
return new Uint8Array(Array.from(input).map(char => char.charCodeAt(0)));
|
|
129
109
|
case 'utf8':
|
|
130
110
|
case 'utf-8':
|
|
111
|
+
return new Uint8Array(Array.from(input).flatMap(char => {
|
|
112
|
+
const code = char.charCodeAt(0);
|
|
113
|
+
if (code < 0x80) {
|
|
114
|
+
return code;
|
|
115
|
+
}
|
|
116
|
+
const a = (code & 0x3f) | 0x80;
|
|
117
|
+
if (code < 0x800) {
|
|
118
|
+
return [(code >> 6) | 0xc0, a];
|
|
119
|
+
}
|
|
120
|
+
const b = ((code >> 6) & 0x3f) | 0x80;
|
|
121
|
+
if (code < 0x10000) {
|
|
122
|
+
return [(code >> 12) | 0xe0, b, a];
|
|
123
|
+
}
|
|
124
|
+
return [(code >> 18) | 0xf0, ((code >> 12) & 0x3f) | 0x80, b, a];
|
|
125
|
+
}));
|
|
131
126
|
case 'base64':
|
|
127
|
+
return encode(atob(input), 'utf-8');
|
|
132
128
|
case 'base64url':
|
|
129
|
+
return encode(input.replace('_', '/').replace('-', '+'), 'base64');
|
|
133
130
|
case 'hex':
|
|
134
|
-
return new
|
|
131
|
+
return new Uint8Array(input.match(/.{1,2}/g).map(e => parseInt(e, 16)));
|
|
135
132
|
case 'utf16le':
|
|
136
133
|
case 'ucs2':
|
|
137
134
|
case 'ucs-2':
|
|
138
|
-
|
|
135
|
+
const u16 = new Uint16Array(new ArrayBuffer(input.length * 2));
|
|
136
|
+
for (let i = 0; i < input.length; i++) {
|
|
137
|
+
u16[i] = input.charCodeAt(i);
|
|
138
|
+
}
|
|
139
|
+
return new Uint8Array(u16.buffer);
|
|
139
140
|
default:
|
|
140
141
|
throw new ApiError(ErrorCode.EINVAL, 'Invalid encoding: ' + encoding);
|
|
141
142
|
}
|
|
@@ -145,14 +146,36 @@ export function encode(input, encoding = 'utf8') {
|
|
|
145
146
|
* @internal
|
|
146
147
|
*/
|
|
147
148
|
export function decode(input, encoding = 'utf8') {
|
|
149
|
+
if (!(input instanceof Uint8Array)) {
|
|
150
|
+
throw new ApiError(ErrorCode.EINVAL, 'Can not decode a non-Uint8Array');
|
|
151
|
+
}
|
|
148
152
|
switch (encoding) {
|
|
149
153
|
case 'ascii':
|
|
150
|
-
case 'utf8':
|
|
151
|
-
case 'utf-8':
|
|
152
|
-
return new globalThis.TextDecoder().decode(input);
|
|
153
154
|
case 'latin1':
|
|
154
155
|
case 'binary':
|
|
155
|
-
return
|
|
156
|
+
return Array.from(input)
|
|
157
|
+
.map(char => String.fromCharCode(char))
|
|
158
|
+
.join('');
|
|
159
|
+
case 'utf8':
|
|
160
|
+
case 'utf-8':
|
|
161
|
+
let utf8String = '';
|
|
162
|
+
for (let i = 0; i < input.length; i++) {
|
|
163
|
+
let code;
|
|
164
|
+
if (input[i] < 0x80) {
|
|
165
|
+
code = input[i];
|
|
166
|
+
}
|
|
167
|
+
else if (input[i] < 0xe0) {
|
|
168
|
+
code = ((input[i] & 0x1f) << 6) | (input[++i] & 0x3f);
|
|
169
|
+
}
|
|
170
|
+
else if (input[i] < 0xf0) {
|
|
171
|
+
code = ((input[i] & 0x0f) << 12) | ((input[++i] & 0x3f) << 6) | (input[++i] & 0x3f);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
code = ((input[i] & 0x07) << 18) | ((input[++i] & 0x3f) << 12) | ((input[++i] & 0x3f) << 6) | (input[++i] & 0x3f);
|
|
175
|
+
}
|
|
176
|
+
utf8String += String.fromCharCode(code);
|
|
177
|
+
}
|
|
178
|
+
return utf8String;
|
|
156
179
|
case 'utf16le':
|
|
157
180
|
case 'ucs2':
|
|
158
181
|
case 'ucs-2':
|
|
@@ -163,14 +186,12 @@ export function decode(input, encoding = 'utf8') {
|
|
|
163
186
|
}
|
|
164
187
|
return utf16leString;
|
|
165
188
|
case 'base64':
|
|
166
|
-
return btoa(
|
|
167
|
-
.map(v => String.fromCharCode(v))
|
|
168
|
-
.join(''));
|
|
189
|
+
return btoa(decode(input, 'utf-8'));
|
|
169
190
|
case 'base64url':
|
|
170
191
|
return decode(input, 'base64').replace('/', '_').replace('+', '-');
|
|
171
192
|
case 'hex':
|
|
172
193
|
return Array.from(input)
|
|
173
|
-
.map(e => e.toString(16))
|
|
194
|
+
.map(e => e.toString(16).padStart(2, '0'))
|
|
174
195
|
.join('');
|
|
175
196
|
default:
|
|
176
197
|
throw new ApiError(ErrorCode.EINVAL, 'Invalid encoding: ' + encoding);
|
package/license.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
ZenFS
|
|
1
|
+
Copyright (c) 2023-2024 James P. and other ZenFS contributors.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Copyright (c) 2013-2023 John Vilk and other ZenFS contributors.
|
|
3
|
+
Copyright (c) 2013-2023 John Vilk and other BrowserFS contributors.
|
|
6
4
|
|
|
7
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
8
6
|
this software and associated documentation files (the "Software"), to deal in
|
|
@@ -22,11 +20,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
22
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
21
|
SOFTWARE.
|
|
24
22
|
|
|
25
|
-
====
|
|
26
|
-
|
|
27
23
|
This license applies to all parts of ZenFS, except for the following items:
|
|
28
24
|
|
|
29
|
-
- The test fixtures located in `test/fixtures/
|
|
25
|
+
- The test fixtures located in `test/fixtures/node`. Their license follows:
|
|
30
26
|
"""
|
|
31
27
|
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
|
32
28
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
@@ -47,76 +43,3 @@ This license applies to all parts of ZenFS, except for the following items:
|
|
|
47
43
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
48
44
|
IN THE SOFTWARE.
|
|
49
45
|
"""
|
|
50
|
-
|
|
51
|
-
- The Emscripten file system in src/generic/emscripten_fs.ts is a modified
|
|
52
|
-
version of Emscripten's NODEFS. Emscripten's license follows:
|
|
53
|
-
"""
|
|
54
|
-
Emscripten is available under 2 licenses, the MIT license and the
|
|
55
|
-
University of Illinois/NCSA Open Source License.
|
|
56
|
-
|
|
57
|
-
Both are permissive open source licenses, with little if any
|
|
58
|
-
practical difference between them.
|
|
59
|
-
|
|
60
|
-
The reason for offering both is that (1) the MIT license is
|
|
61
|
-
well-known, while (2) the University of Illinois/NCSA Open Source
|
|
62
|
-
License allows Emscripten's code to be integrated upstream into
|
|
63
|
-
LLVM, which uses that license, should the opportunity arise.
|
|
64
|
-
|
|
65
|
-
The full text of both licenses follows.
|
|
66
|
-
|
|
67
|
-
==============================================================================
|
|
68
|
-
|
|
69
|
-
Copyright (c) 2010-2011 Emscripten authors, see AUTHORS file.
|
|
70
|
-
|
|
71
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
72
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
73
|
-
in the Software without restriction, including without limitation the rights
|
|
74
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
75
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
76
|
-
furnished to do so, subject to the following conditions:
|
|
77
|
-
|
|
78
|
-
The above copyright notice and this permission notice shall be included in
|
|
79
|
-
all copies or substantial portions of the Software.
|
|
80
|
-
|
|
81
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
82
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
83
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
84
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
85
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
86
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
87
|
-
THE SOFTWARE.
|
|
88
|
-
|
|
89
|
-
==============================================================================
|
|
90
|
-
|
|
91
|
-
Copyright (c) 2010-2011 Emscripten authors, see AUTHORS file.
|
|
92
|
-
All rights reserved.
|
|
93
|
-
|
|
94
|
-
Permission is hereby granted, free of charge, to any person obtaining a
|
|
95
|
-
copy of this software and associated documentation files (the
|
|
96
|
-
"Software"), to deal with the Software without restriction, including
|
|
97
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
98
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
99
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
100
|
-
the following conditions:
|
|
101
|
-
|
|
102
|
-
Redistributions of source code must retain the above copyright
|
|
103
|
-
notice, this list of conditions and the following disclaimers.
|
|
104
|
-
|
|
105
|
-
Redistributions in binary form must reproduce the above
|
|
106
|
-
copyright notice, this list of conditions and the following disclaimers
|
|
107
|
-
in the documentation and/or other materials provided with the
|
|
108
|
-
distribution.
|
|
109
|
-
|
|
110
|
-
Neither the names of Mozilla,
|
|
111
|
-
nor the names of its contributors may be used to endorse
|
|
112
|
-
or promote products derived from this Software without specific prior
|
|
113
|
-
written permission.
|
|
114
|
-
|
|
115
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
116
|
-
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
117
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
118
|
-
IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
119
|
-
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
120
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
121
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
|
|
122
|
-
"""
|
package/package.json
CHANGED
|
@@ -1,65 +1,73 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
2
|
+
"name": "@zenfs/core",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "A filesystem in your browser",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"filesystem",
|
|
9
|
+
"node",
|
|
10
|
+
"storage"
|
|
11
|
+
],
|
|
12
|
+
"bin": {
|
|
13
|
+
"make-index": "scripts/make-index.js"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"homepage": "https://github.com/zen-fs/core",
|
|
17
|
+
"author": "James P. <jp@drvortex.dev> (https://drvortex.dev)",
|
|
18
|
+
"contributors": [
|
|
19
|
+
"John Vilk <jvilk@cs.umass.edu>"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/zen-fs/core.git"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/zen-fs/core/issues"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">= 18"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./dist/index.js",
|
|
34
|
+
"./*": "./dist/*"
|
|
35
|
+
},
|
|
36
|
+
"typesVersions": {
|
|
37
|
+
"*": {
|
|
38
|
+
"*": [
|
|
39
|
+
"./dist/*"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"format": "prettier --write src test",
|
|
45
|
+
"format:check": "prettier --check src test",
|
|
46
|
+
"lint": "eslint src test && tsc -p tsconfig.json --noEmit",
|
|
47
|
+
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules npx jest",
|
|
48
|
+
"build": "node scripts/build.js",
|
|
49
|
+
"build:docs": "typedoc --out docs --name ZenFS src/index.ts",
|
|
50
|
+
"dev": "node scripts/build.js --watch",
|
|
51
|
+
"prepublishOnly": "npm run build"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@types/node": "^14.0.0",
|
|
55
|
+
"@types/readable-stream": "^4.0.10",
|
|
56
|
+
"minimatch": "^9.0.3",
|
|
57
|
+
"readable-stream": "^4.5.2"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@jest/globals": "^29.5.0",
|
|
61
|
+
"@types/jest": "^29.5.1",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^5.55.0",
|
|
63
|
+
"@typescript-eslint/parser": "^5.55.0",
|
|
64
|
+
"cross-env": "^7.0.3",
|
|
65
|
+
"esbuild": "^0.17.18",
|
|
66
|
+
"eslint": "^8.36.0",
|
|
67
|
+
"jest": "^29.5.0",
|
|
68
|
+
"prettier": "^2.8.7",
|
|
69
|
+
"ts-jest": "^29.1.0",
|
|
70
|
+
"typedoc": "^0.25.1",
|
|
71
|
+
"typescript": "^4.9.5"
|
|
72
|
+
}
|
|
65
73
|
}
|