@zenfs/core 0.5.5 → 0.5.7
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/backends/AsyncMirror.d.ts +1 -1
- package/dist/backends/AsyncMirror.js +2 -0
- package/dist/backends/InMemory.d.ts +2 -2
- package/dist/backends/InMemory.js +1 -0
- package/dist/backends/Overlay.d.ts +1 -1
- package/dist/backends/backend.d.ts +1 -1
- package/dist/browser.min.js +4 -4
- package/dist/browser.min.js.map +4 -4
- package/dist/emulation/{callbacks.d.ts → async.d.ts} +53 -16
- package/dist/emulation/{callbacks.js → async.js} +121 -52
- package/dist/emulation/constants.d.ts +5 -0
- package/dist/emulation/constants.js +5 -0
- package/dist/emulation/dir.d.ts +3 -2
- package/dist/emulation/dir.js +6 -2
- package/dist/emulation/index.d.ts +2 -2
- package/dist/emulation/index.js +2 -2
- package/dist/emulation/promises.d.ts +91 -117
- package/dist/emulation/promises.js +106 -105
- package/dist/emulation/shared.d.ts +2 -11
- package/dist/emulation/streams.d.ts +5 -0
- package/dist/emulation/sync.d.ts +49 -14
- package/dist/emulation/sync.js +50 -22
- package/dist/file.d.ts +7 -7
- package/dist/file.js +1 -1
- package/dist/stats.d.ts +32 -16
- package/dist/stats.js +2 -29
- package/dist/utils.d.ts +2 -3
- package/dist/utils.js +6 -92
- package/package.json +8 -5
- package/scripts/build.js +82 -0
- package/scripts/make-index.js +4 -6
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
4
|
import type * as Node from 'fs';
|
|
4
|
-
import {
|
|
5
|
-
import { BigIntStats, type Stats } from '../stats.js';
|
|
5
|
+
import { FileContents, NoArgCallback, ThreeArgCallback, TwoArgCallback } from '../filesystem.js';
|
|
6
|
+
import { BigIntStats, type BigIntStatsFs, type Stats, type StatsFs } from '../stats.js';
|
|
7
|
+
import { Dirent, type Dir } from './dir.js';
|
|
6
8
|
import { PathLike } from './shared.js';
|
|
7
9
|
import { ReadStream, WriteStream } from './streams.js';
|
|
8
|
-
import { Dirent } from './dir.js';
|
|
9
10
|
/**
|
|
10
11
|
* Asynchronous rename. No arguments other than a possible exception are given
|
|
11
12
|
* to the completion callback.
|
|
@@ -19,6 +20,7 @@ export declare function rename(oldPath: PathLike, newPath: PathLike, cb?: NoArgC
|
|
|
19
20
|
* Then call the callback argument with either true or false.
|
|
20
21
|
* @param path
|
|
21
22
|
* @param callback
|
|
23
|
+
* @deprecated Use {@link stat} or {@link access} instead.
|
|
22
24
|
*/
|
|
23
25
|
export declare function exists(path: PathLike, cb?: (exists: boolean) => unknown): void;
|
|
24
26
|
/**
|
|
@@ -102,7 +104,7 @@ export declare function readFile(filename: PathLike, cb: TwoArgCallback<Uint8Arr
|
|
|
102
104
|
export declare function readFile(filename: PathLike, options: {
|
|
103
105
|
flag?: string;
|
|
104
106
|
}, callback?: TwoArgCallback<Uint8Array>): void;
|
|
105
|
-
export declare function readFile(filename: PathLike,
|
|
107
|
+
export declare function readFile(filename: PathLike, options: {
|
|
106
108
|
encoding: BufferEncoding;
|
|
107
109
|
flag?: string;
|
|
108
110
|
} | BufferEncoding, cb: TwoArgCallback<string>): void;
|
|
@@ -197,9 +199,9 @@ export declare function fdatasync(fd: number, cb?: NoArgCallback): void;
|
|
|
197
199
|
* @param callback The number specifies the number of bytes written into the file.
|
|
198
200
|
*/
|
|
199
201
|
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, cb?: ThreeArgCallback<number, Uint8Array>): void;
|
|
200
|
-
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, position
|
|
202
|
+
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: ThreeArgCallback<number, Uint8Array>): void;
|
|
201
203
|
export declare function write(fd: number, data: FileContents, cb?: ThreeArgCallback<number, string>): void;
|
|
202
|
-
export declare function write(fd: number, data: FileContents, position
|
|
204
|
+
export declare function write(fd: number, data: FileContents, position?: number, cb?: ThreeArgCallback<number, string>): void;
|
|
203
205
|
export declare function write(fd: number, data: FileContents, position: number | null, encoding: BufferEncoding, cb?: ThreeArgCallback<number, string>): void;
|
|
204
206
|
/**
|
|
205
207
|
* Read data from the file specified by `fd`.
|
|
@@ -288,8 +290,8 @@ export declare function symlink(target: PathLike, path: PathLike, type?: Node.sy
|
|
|
288
290
|
*/
|
|
289
291
|
export declare function readlink(path: PathLike, callback: TwoArgCallback<string> & any): void;
|
|
290
292
|
export declare function readlink(path: PathLike, options: Node.BufferEncodingOption, callback: TwoArgCallback<Uint8Array>): void;
|
|
291
|
-
export declare function readlink(path: PathLike, options: Node.
|
|
292
|
-
export declare function readlink(path: PathLike, options: Node.
|
|
293
|
+
export declare function readlink(path: PathLike, options: Node.EncodingOption, callback: TwoArgCallback<string | Uint8Array>): void;
|
|
294
|
+
export declare function readlink(path: PathLike, options: Node.EncodingOption, callback: TwoArgCallback<string>): void;
|
|
293
295
|
/**
|
|
294
296
|
* Asynchronous `chown`.
|
|
295
297
|
* @param path
|
|
@@ -344,7 +346,7 @@ export declare function lutimes(path: PathLike, atime: number | Date, mtime: num
|
|
|
344
346
|
* @param callback
|
|
345
347
|
*/
|
|
346
348
|
export declare function realpath(path: PathLike, cb?: TwoArgCallback<string>): void;
|
|
347
|
-
export declare function realpath(path: PathLike, options: Node.
|
|
349
|
+
export declare function realpath(path: PathLike, options: Node.EncodingOption, cb: TwoArgCallback<string>): void;
|
|
348
350
|
/**
|
|
349
351
|
* Asynchronous `access`.
|
|
350
352
|
* @param path
|
|
@@ -353,16 +355,28 @@ export declare function realpath(path: PathLike, options: Node.BaseEncodingOptio
|
|
|
353
355
|
*/
|
|
354
356
|
export declare function access(path: PathLike, cb: NoArgCallback): void;
|
|
355
357
|
export declare function access(path: PathLike, mode: number, cb: NoArgCallback): void;
|
|
358
|
+
/**
|
|
359
|
+
* @todo Implement
|
|
360
|
+
*/
|
|
356
361
|
export declare function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): void;
|
|
357
362
|
export declare function watchFile(filename: PathLike, options: {
|
|
358
363
|
persistent?: boolean;
|
|
359
364
|
interval?: number;
|
|
360
365
|
}, listener: (curr: Stats, prev: Stats) => void): void;
|
|
366
|
+
/**
|
|
367
|
+
* @todo Implement
|
|
368
|
+
*/
|
|
361
369
|
export declare function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
|
|
370
|
+
/**
|
|
371
|
+
* @todo Implement
|
|
372
|
+
*/
|
|
362
373
|
export declare function watch(filename: PathLike, listener?: (event: string, filename: string) => any): Node.FSWatcher;
|
|
363
374
|
export declare function watch(filename: PathLike, options: {
|
|
364
375
|
persistent?: boolean;
|
|
365
376
|
}, listener?: (event: string, filename: string) => any): Node.FSWatcher;
|
|
377
|
+
/**
|
|
378
|
+
* @todo Implement
|
|
379
|
+
*/
|
|
366
380
|
export declare function createReadStream(path: PathLike, options?: {
|
|
367
381
|
flags?: string;
|
|
368
382
|
encoding?: string;
|
|
@@ -370,19 +384,42 @@ export declare function createReadStream(path: PathLike, options?: {
|
|
|
370
384
|
mode?: number;
|
|
371
385
|
autoClose?: boolean;
|
|
372
386
|
}): ReadStream;
|
|
387
|
+
/**
|
|
388
|
+
* @todo Implement
|
|
389
|
+
*/
|
|
373
390
|
export declare function createWriteStream(path: PathLike, options?: {
|
|
374
391
|
flags?: string;
|
|
375
392
|
encoding?: string;
|
|
376
393
|
fd?: number;
|
|
377
394
|
mode?: number;
|
|
378
395
|
}): WriteStream;
|
|
379
|
-
export declare function rm(path: PathLike): void;
|
|
380
|
-
export declare function
|
|
396
|
+
export declare function rm(path: PathLike, callback: NoArgCallback): void;
|
|
397
|
+
export declare function rm(path: PathLike, options: Node.RmOptions, callback: NoArgCallback): void;
|
|
398
|
+
/**
|
|
399
|
+
* Asynchronously creates a unique temporary directory.
|
|
400
|
+
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
401
|
+
*/
|
|
402
|
+
export declare function mkdtemp(prefix: string, callback: TwoArgCallback<string>): void;
|
|
403
|
+
export declare function mkdtemp(prefix: string, options: Node.EncodingOption, callback: TwoArgCallback<string>): void;
|
|
404
|
+
export declare function mkdtemp(prefix: string, options: Node.BufferEncodingOption, callback: TwoArgCallback<Buffer>): void;
|
|
381
405
|
export declare function copyFile(src: PathLike, dest: PathLike, callback: NoArgCallback): void;
|
|
382
406
|
export declare function copyFile(src: PathLike, dest: PathLike, flags: number, callback: NoArgCallback): void;
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
export declare function
|
|
386
|
-
|
|
387
|
-
export declare function
|
|
407
|
+
type readvCb = ThreeArgCallback<number, NodeJS.ArrayBufferView[]>;
|
|
408
|
+
export declare function readv(fd: number, buffers: readonly NodeJS.ArrayBufferView[], cb: readvCb): void;
|
|
409
|
+
export declare function readv(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position: number, cb: readvCb): void;
|
|
410
|
+
type writevCb = ThreeArgCallback<number, NodeJS.ArrayBufferView[]>;
|
|
411
|
+
export declare function writev(fd: number, buffers: NodeJS.ArrayBufferView[], cb: writevCb): void;
|
|
412
|
+
export declare function writev(fd: number, buffers: NodeJS.ArrayBufferView[], position: number, cb: writevCb): void;
|
|
413
|
+
export declare function opendir(path: PathLike, cb: TwoArgCallback<Dir>): void;
|
|
414
|
+
export declare function opendir(path: PathLike, options: Node.OpenDirOptions, cb: TwoArgCallback<Dir>): void;
|
|
415
|
+
export declare function cp(source: PathLike, destination: PathLike, callback: NoArgCallback): void;
|
|
416
|
+
export declare function cp(source: PathLike, destination: PathLike, opts: Node.CopyOptions, callback: NoArgCallback): void;
|
|
417
|
+
export declare function statfs(path: PathLike, callback: TwoArgCallback<StatsFs>): void;
|
|
418
|
+
export declare function statfs(path: PathLike, options: Node.StatFsOptions & {
|
|
419
|
+
bigint?: false;
|
|
420
|
+
}, callback: TwoArgCallback<StatsFs>): void;
|
|
421
|
+
export declare function statfs(path: PathLike, options: Node.StatFsOptions & {
|
|
422
|
+
bigint: true;
|
|
423
|
+
}, callback: TwoArgCallback<BigIntStatsFs>): void;
|
|
424
|
+
export declare function openAsBlob(path: PathLike, options?: Node.OpenAsBlobOptions): Promise<Blob>;
|
|
388
425
|
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ApiError, ErrorCode } from '../ApiError.js';
|
|
2
2
|
import { BigIntStats } from '../stats.js';
|
|
3
|
-
import { fd2file, nop, normalizeMode } from './shared.js';
|
|
4
|
-
import * as promises from './promises.js';
|
|
5
3
|
import { R_OK } from './constants.js';
|
|
6
|
-
import
|
|
4
|
+
import * as promises from './promises.js';
|
|
5
|
+
import { fd2file, nop, normalizeMode } from './shared.js';
|
|
7
6
|
/**
|
|
8
7
|
* Asynchronous rename. No arguments other than a possible exception are given
|
|
9
8
|
* to the completion callback.
|
|
@@ -23,6 +22,7 @@ rename;
|
|
|
23
22
|
* Then call the callback argument with either true or false.
|
|
24
23
|
* @param path
|
|
25
24
|
* @param callback
|
|
25
|
+
* @deprecated Use {@link stat} or {@link access} instead.
|
|
26
26
|
*/
|
|
27
27
|
export function exists(path, cb = nop) {
|
|
28
28
|
promises
|
|
@@ -47,9 +47,9 @@ export function lstat(path, options, callback = nop) {
|
|
|
47
47
|
.catch(callback);
|
|
48
48
|
}
|
|
49
49
|
lstat;
|
|
50
|
-
export function truncate(path,
|
|
51
|
-
cb = typeof
|
|
52
|
-
const len = typeof
|
|
50
|
+
export function truncate(path, cbLen = 0, cb = nop) {
|
|
51
|
+
cb = typeof cbLen === 'function' ? cbLen : cb;
|
|
52
|
+
const len = typeof cbLen === 'number' ? cbLen : 0;
|
|
53
53
|
promises
|
|
54
54
|
.truncate(path, len)
|
|
55
55
|
.then(() => cb())
|
|
@@ -68,9 +68,9 @@ export function unlink(path, cb = nop) {
|
|
|
68
68
|
.catch(cb);
|
|
69
69
|
}
|
|
70
70
|
unlink;
|
|
71
|
-
export function open(path, flag,
|
|
72
|
-
const mode = normalizeMode(
|
|
73
|
-
cb = typeof
|
|
71
|
+
export function open(path, flag, cbMode, cb = nop) {
|
|
72
|
+
const mode = normalizeMode(cbMode, 0o644);
|
|
73
|
+
cb = typeof cbMode === 'function' ? cbMode : cb;
|
|
74
74
|
promises
|
|
75
75
|
.open(path, flag, mode)
|
|
76
76
|
.then(handle => cb(null, handle.fd))
|
|
@@ -85,17 +85,20 @@ export function readFile(filename, options, cb = nop) {
|
|
|
85
85
|
.catch(cb);
|
|
86
86
|
}
|
|
87
87
|
readFile;
|
|
88
|
-
export function writeFile(filename, data,
|
|
89
|
-
cb = typeof
|
|
88
|
+
export function writeFile(filename, data, cbEncOpts, cb = nop) {
|
|
89
|
+
cb = typeof cbEncOpts === 'function' ? cbEncOpts : cb;
|
|
90
90
|
promises
|
|
91
|
-
.writeFile(filename, data, typeof
|
|
91
|
+
.writeFile(filename, data, typeof cbEncOpts != 'function' ? cbEncOpts : null)
|
|
92
92
|
.then(() => cb(null))
|
|
93
93
|
.catch(cb);
|
|
94
94
|
}
|
|
95
95
|
writeFile;
|
|
96
|
-
export function appendFile(filename, data,
|
|
97
|
-
cb = typeof
|
|
98
|
-
promises
|
|
96
|
+
export function appendFile(filename, data, cbEncOpts, cb = nop) {
|
|
97
|
+
cb = typeof cbEncOpts === 'function' ? cbEncOpts : cb;
|
|
98
|
+
promises
|
|
99
|
+
.appendFile(filename, data, typeof cbEncOpts === 'function' ? null : cbEncOpts)
|
|
100
|
+
.then(() => cb())
|
|
101
|
+
.catch(cb);
|
|
99
102
|
}
|
|
100
103
|
appendFile;
|
|
101
104
|
export function fstat(fd, options, cb = nop) {
|
|
@@ -154,45 +157,45 @@ export function fdatasync(fd, cb = nop) {
|
|
|
154
157
|
.catch(cb);
|
|
155
158
|
}
|
|
156
159
|
fdatasync;
|
|
157
|
-
export function write(fd,
|
|
160
|
+
export function write(fd, data, cbPosOff, cbLenEnc, cbPos, cb = nop) {
|
|
158
161
|
let buffer, offset, length, position = null, encoding;
|
|
159
162
|
const handle = new promises.FileHandle(fd);
|
|
160
|
-
if (typeof
|
|
163
|
+
if (typeof data === 'string') {
|
|
161
164
|
// Signature 1: (fd, string, [position?, [encoding?]], cb?)
|
|
162
165
|
encoding = 'utf8';
|
|
163
|
-
switch (typeof
|
|
166
|
+
switch (typeof cbPosOff) {
|
|
164
167
|
case 'function':
|
|
165
168
|
// (fd, string, cb)
|
|
166
|
-
cb =
|
|
169
|
+
cb = cbPosOff;
|
|
167
170
|
break;
|
|
168
171
|
case 'number':
|
|
169
172
|
// (fd, string, position, encoding?, cb?)
|
|
170
|
-
position =
|
|
171
|
-
encoding = (typeof
|
|
172
|
-
cb = typeof
|
|
173
|
+
position = cbPosOff;
|
|
174
|
+
encoding = (typeof cbLenEnc === 'string' ? cbLenEnc : 'utf8');
|
|
175
|
+
cb = typeof cbPos === 'function' ? cbPos : cb;
|
|
173
176
|
break;
|
|
174
177
|
default:
|
|
175
178
|
// ...try to find the callback and get out of here!
|
|
176
|
-
cb = typeof
|
|
179
|
+
cb = typeof cbLenEnc === 'function' ? cbLenEnc : typeof cbPos === 'function' ? cbPos : cb;
|
|
177
180
|
cb(new ApiError(ErrorCode.EINVAL, 'Invalid arguments.'));
|
|
178
181
|
return;
|
|
179
182
|
}
|
|
180
|
-
buffer =
|
|
183
|
+
buffer = Buffer.from(data);
|
|
181
184
|
offset = 0;
|
|
182
185
|
length = buffer.length;
|
|
183
186
|
const _cb = cb;
|
|
184
187
|
handle
|
|
185
188
|
.write(buffer, offset, length, position)
|
|
186
|
-
.then(({ bytesWritten }) => _cb(null, bytesWritten,
|
|
189
|
+
.then(({ bytesWritten }) => _cb(null, bytesWritten, buffer.toString(encoding)))
|
|
187
190
|
.catch(_cb);
|
|
188
191
|
}
|
|
189
192
|
else {
|
|
190
193
|
// Signature 2: (fd, buffer, offset, length, position?, cb?)
|
|
191
|
-
buffer =
|
|
192
|
-
offset =
|
|
193
|
-
length =
|
|
194
|
-
position = typeof
|
|
195
|
-
const _cb = (typeof
|
|
194
|
+
buffer = Buffer.from(data);
|
|
195
|
+
offset = cbPosOff;
|
|
196
|
+
length = cbLenEnc;
|
|
197
|
+
position = typeof cbPos === 'number' ? cbPos : null;
|
|
198
|
+
const _cb = (typeof cbPos === 'function' ? cbPos : cb);
|
|
196
199
|
handle
|
|
197
200
|
.write(buffer, offset, length, position)
|
|
198
201
|
.then(({ bytesWritten }) => _cb(null, bytesWritten, buffer))
|
|
@@ -416,45 +419,111 @@ export function realpath(path, arg2, cb = nop) {
|
|
|
416
419
|
.catch(cb);
|
|
417
420
|
}
|
|
418
421
|
realpath;
|
|
419
|
-
export function access(path,
|
|
420
|
-
const mode = typeof
|
|
421
|
-
cb = typeof
|
|
422
|
+
export function access(path, cbMode, cb = nop) {
|
|
423
|
+
const mode = typeof cbMode === 'number' ? cbMode : R_OK;
|
|
424
|
+
cb = typeof cbMode === 'function' ? cbMode : cb;
|
|
422
425
|
promises
|
|
423
|
-
.access(path, typeof
|
|
426
|
+
.access(path, typeof cbMode === 'function' ? null : cbMode)
|
|
424
427
|
.then(() => cb())
|
|
425
428
|
.catch(cb);
|
|
426
429
|
}
|
|
427
430
|
access;
|
|
428
|
-
export function watchFile(filename,
|
|
429
|
-
throw
|
|
431
|
+
export function watchFile(filename, optsListener, listener = nop) {
|
|
432
|
+
throw ApiError.With('ENOTSUP', filename, 'watchFile');
|
|
430
433
|
}
|
|
434
|
+
watchFile;
|
|
435
|
+
/**
|
|
436
|
+
* @todo Implement
|
|
437
|
+
*/
|
|
431
438
|
export function unwatchFile(filename, listener = nop) {
|
|
432
|
-
throw
|
|
439
|
+
throw ApiError.With('ENOTSUP', filename, 'unwatchFile');
|
|
433
440
|
}
|
|
434
|
-
|
|
435
|
-
|
|
441
|
+
unwatchFile;
|
|
442
|
+
export function watch(filename, options, listener = nop) {
|
|
443
|
+
throw ApiError.With('ENOTSUP', filename, 'watch');
|
|
436
444
|
}
|
|
445
|
+
watch;
|
|
446
|
+
/**
|
|
447
|
+
* @todo Implement
|
|
448
|
+
*/
|
|
437
449
|
export function createReadStream(path, options) {
|
|
438
|
-
throw
|
|
450
|
+
throw ApiError.With('ENOTSUP', path, 'createReadStream');
|
|
439
451
|
}
|
|
452
|
+
createReadStream;
|
|
453
|
+
/**
|
|
454
|
+
* @todo Implement
|
|
455
|
+
*/
|
|
440
456
|
export function createWriteStream(path, options) {
|
|
441
|
-
throw
|
|
457
|
+
throw ApiError.With('ENOTSUP', path, 'createWriteStream');
|
|
442
458
|
}
|
|
443
|
-
|
|
444
|
-
|
|
459
|
+
createWriteStream;
|
|
460
|
+
export function rm(path, options, callback = nop) {
|
|
461
|
+
callback = typeof options === 'function' ? options : callback;
|
|
462
|
+
promises
|
|
463
|
+
.rm(path, typeof options === 'function' ? null : options)
|
|
464
|
+
.then(() => callback(null))
|
|
465
|
+
.catch(callback);
|
|
445
466
|
}
|
|
446
|
-
|
|
447
|
-
|
|
467
|
+
rm;
|
|
468
|
+
export function mkdtemp(prefix, options, callback = nop) {
|
|
469
|
+
callback = typeof options === 'function' ? options : callback;
|
|
470
|
+
promises
|
|
471
|
+
.mkdtemp(prefix, typeof options != 'function' ? options : null)
|
|
472
|
+
.then(result => callback(null, result))
|
|
473
|
+
.catch(callback);
|
|
448
474
|
}
|
|
475
|
+
mkdtemp;
|
|
449
476
|
export function copyFile(src, dest, flags, callback) {
|
|
450
|
-
|
|
477
|
+
callback = typeof flags === 'function' ? flags : callback;
|
|
478
|
+
promises
|
|
479
|
+
.copyFile(src, dest, typeof flags === 'function' ? null : flags)
|
|
480
|
+
.then(() => callback(null))
|
|
481
|
+
.catch(callback);
|
|
482
|
+
}
|
|
483
|
+
copyFile;
|
|
484
|
+
export function readv(fd, buffers, position, cb = nop) {
|
|
485
|
+
cb = typeof position === 'function' ? position : cb;
|
|
486
|
+
new promises.FileHandle(fd)
|
|
487
|
+
.readv(buffers, typeof position === 'function' ? null : position)
|
|
488
|
+
.then(({ buffers, bytesRead }) => cb(null, bytesRead, buffers))
|
|
489
|
+
.catch(cb);
|
|
451
490
|
}
|
|
452
|
-
|
|
453
|
-
|
|
491
|
+
readv;
|
|
492
|
+
export function writev(fd, buffers, position, cb = nop) {
|
|
493
|
+
cb = typeof position === 'function' ? position : cb;
|
|
494
|
+
new promises.FileHandle(fd)
|
|
495
|
+
.writev(buffers, typeof position === 'function' ? null : position)
|
|
496
|
+
.then(({ buffers, bytesWritten }) => cb(null, bytesWritten, buffers))
|
|
497
|
+
.catch(cb);
|
|
454
498
|
}
|
|
455
|
-
|
|
456
|
-
|
|
499
|
+
writev;
|
|
500
|
+
export function opendir(path, options, cb = nop) {
|
|
501
|
+
cb = typeof options === 'function' ? options : cb;
|
|
502
|
+
promises
|
|
503
|
+
.opendir(path, typeof options === 'function' ? null : options)
|
|
504
|
+
.then(result => cb(null, result))
|
|
505
|
+
.catch(cb);
|
|
506
|
+
}
|
|
507
|
+
opendir;
|
|
508
|
+
export function cp(source, destination, opts, callback) {
|
|
509
|
+
callback = typeof opts === 'function' ? opts : callback;
|
|
510
|
+
promises
|
|
511
|
+
.cp(source, destination, typeof opts === 'function' ? null : opts)
|
|
512
|
+
.then(() => callback(null))
|
|
513
|
+
.catch(callback);
|
|
514
|
+
}
|
|
515
|
+
cp;
|
|
516
|
+
export function statfs(path, options, callback = nop) {
|
|
517
|
+
callback = typeof options === 'function' ? options : callback;
|
|
518
|
+
promises
|
|
519
|
+
.statfs(path, typeof options === 'function' ? null : options)
|
|
520
|
+
.then(result => callback(null, result))
|
|
521
|
+
.catch(callback);
|
|
457
522
|
}
|
|
458
|
-
|
|
459
|
-
|
|
523
|
+
statfs;
|
|
524
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
525
|
+
export function openAsBlob(path, options) {
|
|
526
|
+
throw ApiError.With('ENOTSUP', path, 'openAsBlob');
|
|
460
527
|
}
|
|
528
|
+
openAsBlob;
|
|
529
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
@@ -105,3 +105,8 @@ export declare const S_IROTH = 4;
|
|
|
105
105
|
export declare const S_IWOTH = 2;
|
|
106
106
|
/** File mode indicating executable by others. */
|
|
107
107
|
export declare const S_IXOTH = 1;
|
|
108
|
+
/**
|
|
109
|
+
* When set, a memory file mapping is used to access the file.
|
|
110
|
+
* This flag is ignored since a unix-like FS is emulated
|
|
111
|
+
*/
|
|
112
|
+
export declare const UV_FS_O_FILEMAP = 0;
|
|
@@ -117,3 +117,8 @@ export const S_IROTH = 4;
|
|
|
117
117
|
export const S_IWOTH = 2;
|
|
118
118
|
/** File mode indicating executable by others. */
|
|
119
119
|
export const S_IXOTH = 1;
|
|
120
|
+
/**
|
|
121
|
+
* When set, a memory file mapping is used to access the file.
|
|
122
|
+
* This flag is ignored since a unix-like FS is emulated
|
|
123
|
+
*/
|
|
124
|
+
export const UV_FS_O_FILEMAP = 0;
|
package/dist/emulation/dir.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ import type { Dirent as _Dirent, Dir as _Dir } from 'fs';
|
|
|
3
3
|
import type { NoArgCallback, TwoArgCallback } from '../filesystem.js';
|
|
4
4
|
import type { Stats } from '../stats.js';
|
|
5
5
|
export declare class Dirent implements _Dirent {
|
|
6
|
-
|
|
6
|
+
path: string;
|
|
7
7
|
protected stats: Stats;
|
|
8
|
-
|
|
8
|
+
get name(): string;
|
|
9
|
+
constructor(path: string, stats: Stats);
|
|
9
10
|
isFile(): boolean;
|
|
10
11
|
isDirectory(): boolean;
|
|
11
12
|
isBlockDevice(): boolean;
|
package/dist/emulation/dir.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { readdir } from './promises.js';
|
|
2
2
|
import { ApiError, ErrorCode } from '../ApiError.js';
|
|
3
3
|
import { readdirSync } from './sync.js';
|
|
4
|
+
import { basename } from './path.js';
|
|
4
5
|
export class Dirent {
|
|
5
|
-
|
|
6
|
-
this.
|
|
6
|
+
get name() {
|
|
7
|
+
return basename(this.path);
|
|
8
|
+
}
|
|
9
|
+
constructor(path, stats) {
|
|
10
|
+
this.path = path;
|
|
7
11
|
this.stats = stats;
|
|
8
12
|
}
|
|
9
13
|
isFile() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './async.js';
|
|
2
2
|
export * from './sync.js';
|
|
3
3
|
export * as promises from './promises.js';
|
|
4
4
|
export * as constants from './constants.js';
|
|
5
5
|
export * from './streams.js';
|
|
6
6
|
export * from './dir.js';
|
|
7
7
|
export { initialize, mounts, mount, umount, _toUnixTimestamp } from './shared.js';
|
|
8
|
-
export { Stats, BigIntStats } from '../stats.js';
|
|
8
|
+
export { Stats, BigIntStats, StatsFs } from '../stats.js';
|
package/dist/emulation/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './async.js';
|
|
2
2
|
export * from './sync.js';
|
|
3
3
|
export * as promises from './promises.js';
|
|
4
4
|
export * as constants from './constants.js';
|
|
5
5
|
export * from './streams.js';
|
|
6
6
|
export * from './dir.js';
|
|
7
7
|
export { initialize, mounts, mount, umount, _toUnixTimestamp } from './shared.js';
|
|
8
|
-
export { Stats, BigIntStats } from '../stats.js';
|
|
8
|
+
export { Stats, BigIntStats, StatsFs } from '../stats.js';
|