memfs 4.0.0 → 4.1.0
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/LICENSE +201 -24
- package/README.md +21 -92
- package/lib/Dirent.d.ts +2 -1
- package/lib/__tests__/util.d.ts +13 -0
- package/lib/__tests__/util.js +29 -0
- package/lib/consts/AMODE.d.ts +9 -0
- package/lib/consts/FLAG.d.ts +22 -0
- package/lib/consts/FLAG.js +2 -0
- package/lib/fsa/types.d.ts +3 -3
- package/lib/fsa-to-node/FsaNodeCore.d.ts +32 -0
- package/lib/fsa-to-node/FsaNodeCore.js +168 -0
- package/lib/fsa-to-node/FsaNodeDirent.d.ts +13 -0
- package/lib/fsa-to-node/FsaNodeDirent.js +31 -0
- package/lib/fsa-to-node/FsaNodeFs.d.ts +171 -0
- package/lib/fsa-to-node/FsaNodeFs.js +842 -0
- package/lib/fsa-to-node/FsaNodeFsOpenFile.d.ts +24 -0
- package/lib/fsa-to-node/FsaNodeFsOpenFile.js +46 -0
- package/lib/fsa-to-node/FsaNodeReadStream.d.ts +24 -0
- package/lib/fsa-to-node/FsaNodeReadStream.js +100 -0
- package/lib/fsa-to-node/FsaNodeStats.d.ts +30 -0
- package/lib/fsa-to-node/FsaNodeStats.js +52 -0
- package/lib/fsa-to-node/FsaNodeWriteStream.d.ts +48 -0
- package/lib/fsa-to-node/FsaNodeWriteStream.js +162 -0
- package/lib/fsa-to-node/__tests__/FsaNodeFs.test.d.ts +1 -0
- package/lib/fsa-to-node/__tests__/FsaNodeFs.test.js +873 -0
- package/lib/fsa-to-node/__tests__/util.test.d.ts +1 -0
- package/lib/fsa-to-node/__tests__/util.test.js +28 -0
- package/lib/fsa-to-node/constants.d.ts +3 -0
- package/lib/fsa-to-node/constants.js +2 -0
- package/lib/fsa-to-node/index.d.ts +2 -0
- package/lib/fsa-to-node/index.js +7 -0
- package/lib/fsa-to-node/json.d.ts +4 -0
- package/lib/fsa-to-node/json.js +7 -0
- package/lib/fsa-to-node/types.d.ts +37 -0
- package/lib/fsa-to-node/types.js +2 -0
- package/lib/fsa-to-node/util.d.ts +4 -0
- package/lib/fsa-to-node/util.js +40 -0
- package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.d.ts +10 -0
- package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js +72 -0
- package/lib/fsa-to-node/worker/FsaNodeSyncWorker.d.ts +20 -0
- package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js +190 -0
- package/lib/fsa-to-node/worker/SyncMessenger.d.ts +24 -0
- package/lib/fsa-to-node/worker/SyncMessenger.js +80 -0
- package/lib/fsa-to-node/worker/constants.d.ts +8 -0
- package/lib/fsa-to-node/worker/constants.js +2 -0
- package/lib/fsa-to-node/worker/types.d.ts +17 -0
- package/lib/fsa-to-node/worker/types.js +2 -0
- package/lib/index.d.ts +5 -4
- package/lib/index.js +1 -1
- package/lib/node/constants.d.ts +41 -0
- package/lib/node/constants.js +56 -0
- package/lib/node/options.d.ts +23 -0
- package/lib/node/options.js +94 -0
- package/lib/node/promises.d.ts +1 -1
- package/lib/node/promises.js +1 -3
- package/lib/node/types/FsCommonObjects.d.ts +17 -0
- package/lib/node/types/FsCommonObjects.js +2 -0
- package/lib/node/types/{sync.d.ts → FsSynchronousApi.d.ts} +36 -37
- package/lib/node/types/FsSynchronousApi.js +2 -0
- package/lib/node/types/callback.d.ts +57 -58
- package/lib/node/types/index.d.ts +1 -1
- package/lib/node/types/misc.d.ts +6 -8
- package/lib/node/types/options.d.ts +20 -6
- package/lib/node/types/promises.d.ts +2 -2
- package/lib/node/util.d.ts +19 -0
- package/lib/node/util.js +265 -1
- package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.d.ts +71 -0
- package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js +264 -0
- package/lib/node-to-fsa/NodeFileSystemFileHandle.d.ts +28 -0
- package/lib/node-to-fsa/NodeFileSystemFileHandle.js +73 -0
- package/lib/node-to-fsa/NodeFileSystemHandle.d.ts +33 -0
- package/lib/node-to-fsa/NodeFileSystemHandle.js +53 -0
- package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.d.ts +42 -0
- package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js +116 -0
- package/lib/node-to-fsa/NodeFileSystemWritableFileStream.d.ts +54 -0
- package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js +195 -0
- package/lib/node-to-fsa/NodePermissionStatus.d.ts +8 -0
- package/lib/node-to-fsa/NodePermissionStatus.js +13 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.d.ts +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.js +627 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemFileHandle.test.d.ts +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemFileHandle.test.js +191 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemHandle.test.d.ts +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemHandle.test.js +49 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemSyncAccessHandle.test.d.ts +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemSyncAccessHandle.test.js +183 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemWritableFileStream.test.d.ts +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemWritableFileStream.test.js +106 -0
- package/lib/node-to-fsa/__tests__/scenarios.test.d.ts +1 -0
- package/lib/node-to-fsa/__tests__/scenarios.test.js +46 -0
- package/lib/node-to-fsa/__tests__/util.test.d.ts +1 -0
- package/lib/node-to-fsa/__tests__/util.test.js +25 -0
- package/lib/node-to-fsa/index.d.ts +7 -0
- package/lib/node-to-fsa/index.js +26 -0
- package/lib/node-to-fsa/types.d.ts +12 -0
- package/lib/node-to-fsa/types.js +2 -0
- package/lib/node-to-fsa/util.d.ts +11 -0
- package/lib/node-to-fsa/util.js +33 -0
- package/lib/node.d.ts +1 -1
- package/lib/volume.d.ts +45 -126
- package/lib/volume.js +204 -562
- package/lib/webfs/index.d.ts +1 -0
- package/lib/webfs/index.js +22 -0
- package/package.json +28 -5
- /package/lib/{node/types/sync.js → consts/AMODE.js} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare const enum MODE {
|
|
2
|
+
FILE = 438,
|
|
3
|
+
DIR = 511,
|
|
4
|
+
DEFAULT = 438
|
|
5
|
+
}
|
|
6
|
+
export declare const ERRSTR: {
|
|
7
|
+
PATH_STR: string;
|
|
8
|
+
FD: string;
|
|
9
|
+
MODE_INT: string;
|
|
10
|
+
CB: string;
|
|
11
|
+
UID: string;
|
|
12
|
+
GID: string;
|
|
13
|
+
LEN: string;
|
|
14
|
+
ATIME: string;
|
|
15
|
+
MTIME: string;
|
|
16
|
+
PREFIX: string;
|
|
17
|
+
BUFFER: string;
|
|
18
|
+
OFFSET: string;
|
|
19
|
+
LENGTH: string;
|
|
20
|
+
POSITION: string;
|
|
21
|
+
};
|
|
22
|
+
export declare enum FLAGS {
|
|
23
|
+
r,
|
|
24
|
+
'r+',
|
|
25
|
+
rs,
|
|
26
|
+
sr,
|
|
27
|
+
'rs+',
|
|
28
|
+
'sr+',
|
|
29
|
+
w,
|
|
30
|
+
wx,
|
|
31
|
+
xw,
|
|
32
|
+
'w+',
|
|
33
|
+
'wx+',
|
|
34
|
+
'xw+',
|
|
35
|
+
a,
|
|
36
|
+
ax,
|
|
37
|
+
xa,
|
|
38
|
+
'a+',
|
|
39
|
+
'ax+',
|
|
40
|
+
'xa+'
|
|
41
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FLAGS = exports.ERRSTR = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
exports.ERRSTR = {
|
|
6
|
+
PATH_STR: 'path must be a string or Buffer',
|
|
7
|
+
// FD: 'file descriptor must be a unsigned 32-bit integer',
|
|
8
|
+
FD: 'fd must be a file descriptor',
|
|
9
|
+
MODE_INT: 'mode must be an int',
|
|
10
|
+
CB: 'callback must be a function',
|
|
11
|
+
UID: 'uid must be an unsigned int',
|
|
12
|
+
GID: 'gid must be an unsigned int',
|
|
13
|
+
LEN: 'len must be an integer',
|
|
14
|
+
ATIME: 'atime must be an integer',
|
|
15
|
+
MTIME: 'mtime must be an integer',
|
|
16
|
+
PREFIX: 'filename prefix is required',
|
|
17
|
+
BUFFER: 'buffer must be an instance of Buffer or StaticBuffer',
|
|
18
|
+
OFFSET: 'offset must be an integer',
|
|
19
|
+
LENGTH: 'length must be an integer',
|
|
20
|
+
POSITION: 'position must be an integer',
|
|
21
|
+
};
|
|
22
|
+
const { O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_TRUNC, O_APPEND, O_SYNC } = constants_1.constants;
|
|
23
|
+
// List of file `flags` as defined by Node.
|
|
24
|
+
var FLAGS;
|
|
25
|
+
(function (FLAGS) {
|
|
26
|
+
// Open file for reading. An exception occurs if the file does not exist.
|
|
27
|
+
FLAGS[FLAGS["r"] = O_RDONLY] = "r";
|
|
28
|
+
// Open file for reading and writing. An exception occurs if the file does not exist.
|
|
29
|
+
FLAGS[FLAGS["r+"] = O_RDWR] = "r+";
|
|
30
|
+
// Open file for reading in synchronous mode. Instructs the operating system to bypass the local file system cache.
|
|
31
|
+
FLAGS[FLAGS["rs"] = O_RDONLY | O_SYNC] = "rs";
|
|
32
|
+
FLAGS[FLAGS["sr"] = FLAGS.rs] = "sr";
|
|
33
|
+
// Open file for reading and writing, telling the OS to open it synchronously. See notes for 'rs' about using this with caution.
|
|
34
|
+
FLAGS[FLAGS["rs+"] = O_RDWR | O_SYNC] = "rs+";
|
|
35
|
+
FLAGS[FLAGS["sr+"] = FLAGS['rs+']] = "sr+";
|
|
36
|
+
// Open file for writing. The file is created (if it does not exist) or truncated (if it exists).
|
|
37
|
+
FLAGS[FLAGS["w"] = O_WRONLY | O_CREAT | O_TRUNC] = "w";
|
|
38
|
+
// Like 'w' but fails if path exists.
|
|
39
|
+
FLAGS[FLAGS["wx"] = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL] = "wx";
|
|
40
|
+
FLAGS[FLAGS["xw"] = FLAGS.wx] = "xw";
|
|
41
|
+
// Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).
|
|
42
|
+
FLAGS[FLAGS["w+"] = O_RDWR | O_CREAT | O_TRUNC] = "w+";
|
|
43
|
+
// Like 'w+' but fails if path exists.
|
|
44
|
+
FLAGS[FLAGS["wx+"] = O_RDWR | O_CREAT | O_TRUNC | O_EXCL] = "wx+";
|
|
45
|
+
FLAGS[FLAGS["xw+"] = FLAGS['wx+']] = "xw+";
|
|
46
|
+
// Open file for appending. The file is created if it does not exist.
|
|
47
|
+
FLAGS[FLAGS["a"] = O_WRONLY | O_APPEND | O_CREAT] = "a";
|
|
48
|
+
// Like 'a' but fails if path exists.
|
|
49
|
+
FLAGS[FLAGS["ax"] = O_WRONLY | O_APPEND | O_CREAT | O_EXCL] = "ax";
|
|
50
|
+
FLAGS[FLAGS["xa"] = FLAGS.ax] = "xa";
|
|
51
|
+
// Open file for reading and appending. The file is created if it does not exist.
|
|
52
|
+
FLAGS[FLAGS["a+"] = O_RDWR | O_APPEND | O_CREAT] = "a+";
|
|
53
|
+
// Like 'a+' but fails if path exists.
|
|
54
|
+
FLAGS[FLAGS["ax+"] = O_RDWR | O_APPEND | O_CREAT | O_EXCL] = "ax+";
|
|
55
|
+
FLAGS[FLAGS["xa+"] = FLAGS['ax+']] = "xa+";
|
|
56
|
+
})(FLAGS = exports.FLAGS || (exports.FLAGS = {}));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type * as opts from './types/options';
|
|
2
|
+
import * as misc from './types/misc';
|
|
3
|
+
import { IAppendFileOptions } from '../volume';
|
|
4
|
+
export declare const getMkdirOptions: (options: any) => opts.IMkdirOptions;
|
|
5
|
+
export declare function getOptions<T extends opts.IOptions>(defaults: T, options?: T | string): T;
|
|
6
|
+
export declare function optsGenerator<TOpts>(defaults: TOpts): (opts: any) => TOpts;
|
|
7
|
+
export declare function optsAndCbGenerator<TOpts, TResult>(getOpts: any): (options: any, callback?: any) => [TOpts, misc.TCallback<TResult>];
|
|
8
|
+
export declare const optsDefaults: opts.IOptions;
|
|
9
|
+
export declare const getDefaultOpts: (opts: any) => opts.IOptions;
|
|
10
|
+
export declare const getDefaultOptsAndCb: (options: any, callback?: any) => [opts.IOptions, misc.TCallback<any>];
|
|
11
|
+
export declare const getRmdirOptions: (options: any) => opts.IRmdirOptions;
|
|
12
|
+
export declare const getRmOptsAndCb: (options: any, callback?: any) => [opts.IRmOptions, misc.TCallback<any>];
|
|
13
|
+
export declare const getReadFileOptions: (opts: any) => opts.IReadFileOptions;
|
|
14
|
+
export declare const getReaddirOptions: (opts: any) => opts.IReaddirOptions;
|
|
15
|
+
export declare const getReaddirOptsAndCb: (options: any, callback?: any) => [opts.IReaddirOptions, misc.TCallback<misc.TDataOut[] | misc.IDirent[]>];
|
|
16
|
+
export declare const getAppendFileOpts: (opts: any) => IAppendFileOptions;
|
|
17
|
+
export declare const getAppendFileOptsAndCb: (options: any, callback?: any) => [IAppendFileOptions, misc.TCallback<void>];
|
|
18
|
+
export declare const getStatOptions: (options?: any) => opts.IStatOptions;
|
|
19
|
+
export declare const getStatOptsAndCb: (options: any, callback?: misc.TCallback<misc.IStats>) => [opts.IStatOptions, misc.TCallback<misc.IStats>];
|
|
20
|
+
export declare const getRealpathOptions: (opts: any) => opts.IRealpathOptions;
|
|
21
|
+
export declare const getRealpathOptsAndCb: (options: any, callback?: any) => [opts.IRealpathOptions, misc.TCallback<misc.TDataOut>];
|
|
22
|
+
export declare const writeFileDefaults: opts.IWriteFileOptions;
|
|
23
|
+
export declare const getWriteFileOptions: (opts: any) => opts.IWriteFileOptions;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWriteFileOptions = exports.writeFileDefaults = exports.getRealpathOptsAndCb = exports.getRealpathOptions = exports.getStatOptsAndCb = exports.getStatOptions = exports.getAppendFileOptsAndCb = exports.getAppendFileOpts = exports.getReaddirOptsAndCb = exports.getReaddirOptions = exports.getReadFileOptions = exports.getRmOptsAndCb = exports.getRmdirOptions = exports.getDefaultOptsAndCb = exports.getDefaultOpts = exports.optsDefaults = exports.optsAndCbGenerator = exports.optsGenerator = exports.getOptions = exports.getMkdirOptions = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const encoding_1 = require("../encoding");
|
|
6
|
+
const util_1 = require("./util");
|
|
7
|
+
const mkdirDefaults = {
|
|
8
|
+
mode: 511 /* MODE.DIR */,
|
|
9
|
+
recursive: false,
|
|
10
|
+
};
|
|
11
|
+
const getMkdirOptions = (options) => {
|
|
12
|
+
if (typeof options === 'number')
|
|
13
|
+
return Object.assign({}, mkdirDefaults, { mode: options });
|
|
14
|
+
return Object.assign({}, mkdirDefaults, options);
|
|
15
|
+
};
|
|
16
|
+
exports.getMkdirOptions = getMkdirOptions;
|
|
17
|
+
const ERRSTR_OPTS = tipeof => `Expected options to be either an object or a string, but got ${tipeof} instead`;
|
|
18
|
+
function getOptions(defaults, options) {
|
|
19
|
+
let opts;
|
|
20
|
+
if (!options)
|
|
21
|
+
return defaults;
|
|
22
|
+
else {
|
|
23
|
+
const tipeof = typeof options;
|
|
24
|
+
switch (tipeof) {
|
|
25
|
+
case 'string':
|
|
26
|
+
opts = Object.assign({}, defaults, { encoding: options });
|
|
27
|
+
break;
|
|
28
|
+
case 'object':
|
|
29
|
+
opts = Object.assign({}, defaults, options);
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
throw TypeError(ERRSTR_OPTS(tipeof));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (opts.encoding !== 'buffer')
|
|
36
|
+
(0, encoding_1.assertEncoding)(opts.encoding);
|
|
37
|
+
return opts;
|
|
38
|
+
}
|
|
39
|
+
exports.getOptions = getOptions;
|
|
40
|
+
function optsGenerator(defaults) {
|
|
41
|
+
return options => getOptions(defaults, options);
|
|
42
|
+
}
|
|
43
|
+
exports.optsGenerator = optsGenerator;
|
|
44
|
+
function optsAndCbGenerator(getOpts) {
|
|
45
|
+
return (options, callback) => typeof options === 'function' ? [getOpts(), options] : [getOpts(options), (0, util_1.validateCallback)(callback)];
|
|
46
|
+
}
|
|
47
|
+
exports.optsAndCbGenerator = optsAndCbGenerator;
|
|
48
|
+
exports.optsDefaults = {
|
|
49
|
+
encoding: 'utf8',
|
|
50
|
+
};
|
|
51
|
+
exports.getDefaultOpts = optsGenerator(exports.optsDefaults);
|
|
52
|
+
exports.getDefaultOptsAndCb = optsAndCbGenerator(exports.getDefaultOpts);
|
|
53
|
+
const rmdirDefaults = {
|
|
54
|
+
recursive: false,
|
|
55
|
+
};
|
|
56
|
+
const getRmdirOptions = (options) => {
|
|
57
|
+
return Object.assign({}, rmdirDefaults, options);
|
|
58
|
+
};
|
|
59
|
+
exports.getRmdirOptions = getRmdirOptions;
|
|
60
|
+
const getRmOpts = optsGenerator(exports.optsDefaults);
|
|
61
|
+
exports.getRmOptsAndCb = optsAndCbGenerator(getRmOpts);
|
|
62
|
+
const readFileOptsDefaults = {
|
|
63
|
+
flag: 'r',
|
|
64
|
+
};
|
|
65
|
+
exports.getReadFileOptions = optsGenerator(readFileOptsDefaults);
|
|
66
|
+
const readdirDefaults = {
|
|
67
|
+
encoding: 'utf8',
|
|
68
|
+
withFileTypes: false,
|
|
69
|
+
};
|
|
70
|
+
exports.getReaddirOptions = optsGenerator(readdirDefaults);
|
|
71
|
+
exports.getReaddirOptsAndCb = optsAndCbGenerator(exports.getReaddirOptions);
|
|
72
|
+
const appendFileDefaults = {
|
|
73
|
+
encoding: 'utf8',
|
|
74
|
+
mode: 438 /* MODE.DEFAULT */,
|
|
75
|
+
flag: constants_1.FLAGS[constants_1.FLAGS.a],
|
|
76
|
+
};
|
|
77
|
+
exports.getAppendFileOpts = optsGenerator(appendFileDefaults);
|
|
78
|
+
exports.getAppendFileOptsAndCb = optsAndCbGenerator(exports.getAppendFileOpts);
|
|
79
|
+
const statDefaults = {
|
|
80
|
+
bigint: false,
|
|
81
|
+
};
|
|
82
|
+
const getStatOptions = (options = {}) => Object.assign({}, statDefaults, options);
|
|
83
|
+
exports.getStatOptions = getStatOptions;
|
|
84
|
+
const getStatOptsAndCb = (options, callback) => typeof options === 'function' ? [(0, exports.getStatOptions)(), options] : [(0, exports.getStatOptions)(options), (0, util_1.validateCallback)(callback)];
|
|
85
|
+
exports.getStatOptsAndCb = getStatOptsAndCb;
|
|
86
|
+
const realpathDefaults = exports.optsDefaults;
|
|
87
|
+
exports.getRealpathOptions = optsGenerator(realpathDefaults);
|
|
88
|
+
exports.getRealpathOptsAndCb = optsAndCbGenerator(exports.getRealpathOptions);
|
|
89
|
+
exports.writeFileDefaults = {
|
|
90
|
+
encoding: 'utf8',
|
|
91
|
+
mode: 438 /* MODE.DEFAULT */,
|
|
92
|
+
flag: constants_1.FLAGS[constants_1.FLAGS.w],
|
|
93
|
+
};
|
|
94
|
+
exports.getWriteFileOptions = optsGenerator(exports.writeFileDefaults);
|
package/lib/node/promises.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { FsCallbackApi, FsPromisesApi } from './types';
|
|
2
|
-
export declare function createPromisesApi(vol: FsCallbackApi):
|
|
2
|
+
export declare function createPromisesApi(vol: FsCallbackApi): FsPromisesApi;
|
package/lib/node/promises.js
CHANGED
|
@@ -4,8 +4,6 @@ exports.createPromisesApi = void 0;
|
|
|
4
4
|
const FileHandle_1 = require("./FileHandle");
|
|
5
5
|
const util_1 = require("./util");
|
|
6
6
|
function createPromisesApi(vol) {
|
|
7
|
-
if (typeof Promise === 'undefined')
|
|
8
|
-
return null;
|
|
9
7
|
return {
|
|
10
8
|
FileHandle: FileHandle_1.FileHandle,
|
|
11
9
|
access(path, mode) {
|
|
@@ -41,7 +39,7 @@ function createPromisesApi(vol) {
|
|
|
41
39
|
mkdtemp(prefix, options) {
|
|
42
40
|
return (0, util_1.promisify)(vol, 'mkdtemp')(prefix, options);
|
|
43
41
|
},
|
|
44
|
-
open(path, flags, mode) {
|
|
42
|
+
open(path, flags = 'r', mode) {
|
|
45
43
|
return (0, util_1.promisify)(vol, 'open', fd => new FileHandle_1.FileHandle(vol, fd))(path, flags, mode);
|
|
46
44
|
},
|
|
47
45
|
readdir(path, options) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { constants } from '../../constants';
|
|
2
|
+
import type * as misc from './misc';
|
|
3
|
+
export interface FsCommonObjects {
|
|
4
|
+
F_OK: number;
|
|
5
|
+
R_OK: number;
|
|
6
|
+
W_OK: number;
|
|
7
|
+
X_OK: number;
|
|
8
|
+
constants: typeof constants;
|
|
9
|
+
Stats: new (...args: unknown[]) => misc.IStats;
|
|
10
|
+
StatFs: unknown;
|
|
11
|
+
Dir: unknown;
|
|
12
|
+
Dirent: new (...args: unknown[]) => misc.IDirent;
|
|
13
|
+
StatsWatcher: new (...args: unknown[]) => misc.IStatWatcher;
|
|
14
|
+
FSWatcher: new (...args: unknown[]) => misc.IFSWatcher;
|
|
15
|
+
ReadStream: new (...args: unknown[]) => misc.IReadStream;
|
|
16
|
+
WriteStream: new (...args: unknown[]) => misc.IWriteStream;
|
|
17
|
+
}
|
|
@@ -1,64 +1,63 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import type { PathLike, symlink } from 'fs';
|
|
4
3
|
import type * as misc from './misc';
|
|
5
4
|
import type * as opts from './options';
|
|
6
5
|
export interface FsSynchronousApi {
|
|
7
|
-
openSync(path: PathLike, flags: misc.TFlags, mode?: misc.TMode): number;
|
|
6
|
+
openSync(path: misc.PathLike, flags: misc.TFlags, mode?: misc.TMode): number;
|
|
8
7
|
closeSync(fd: number): void;
|
|
9
8
|
readSync(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, position: number): number;
|
|
10
9
|
readFileSync(file: misc.TFileId, options?: opts.IReadFileOptions | string): misc.TDataOut;
|
|
11
10
|
writeSync(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset?: number, length?: number, position?: number): number;
|
|
12
11
|
writeSync(fd: number, str: string, position?: number, encoding?: BufferEncoding): number;
|
|
13
12
|
writeFileSync(id: misc.TFileId, data: misc.TData, options?: opts.IWriteFileOptions): void;
|
|
14
|
-
copyFileSync(src: PathLike, dest: PathLike, flags?: misc.TFlagsCopy): void;
|
|
15
|
-
linkSync(existingPath: PathLike, newPath: PathLike): void;
|
|
16
|
-
unlinkSync(path: PathLike): void;
|
|
17
|
-
symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type): void;
|
|
18
|
-
realpathSync(path: PathLike, options?: opts.IRealpathOptions | string): misc.TDataOut;
|
|
19
|
-
lstatSync(path: PathLike): misc.IStats<number>;
|
|
20
|
-
lstatSync(path: PathLike, options: {
|
|
13
|
+
copyFileSync(src: misc.PathLike, dest: misc.PathLike, flags?: misc.TFlagsCopy): void;
|
|
14
|
+
linkSync(existingPath: misc.PathLike, newPath: misc.PathLike): void;
|
|
15
|
+
unlinkSync(path: misc.PathLike): void;
|
|
16
|
+
symlinkSync(target: misc.PathLike, path: misc.PathLike, type?: misc.symlink.Type): void;
|
|
17
|
+
realpathSync(path: misc.PathLike, options?: opts.IRealpathOptions | string): misc.TDataOut;
|
|
18
|
+
lstatSync(path: misc.PathLike): misc.IStats<number>;
|
|
19
|
+
lstatSync(path: misc.PathLike, options: {
|
|
21
20
|
throwIfNoEntry?: true | undefined;
|
|
22
21
|
}): misc.IStats<number>;
|
|
23
|
-
lstatSync(path: PathLike, options: {
|
|
22
|
+
lstatSync(path: misc.PathLike, options: {
|
|
24
23
|
bigint: false;
|
|
25
24
|
throwIfNoEntry?: true | undefined;
|
|
26
25
|
}): misc.IStats<number>;
|
|
27
|
-
lstatSync(path: PathLike, options: {
|
|
26
|
+
lstatSync(path: misc.PathLike, options: {
|
|
28
27
|
bigint: true;
|
|
29
28
|
throwIfNoEntry?: true | undefined;
|
|
30
29
|
}): misc.IStats<bigint>;
|
|
31
|
-
lstatSync(path: PathLike, options: {
|
|
30
|
+
lstatSync(path: misc.PathLike, options: {
|
|
32
31
|
throwIfNoEntry: false;
|
|
33
32
|
}): misc.IStats<number> | undefined;
|
|
34
|
-
lstatSync(path: PathLike, options: {
|
|
33
|
+
lstatSync(path: misc.PathLike, options: {
|
|
35
34
|
bigint: false;
|
|
36
35
|
throwIfNoEntry: false;
|
|
37
36
|
}): misc.IStats<number> | undefined;
|
|
38
|
-
lstatSync(path: PathLike, options: {
|
|
37
|
+
lstatSync(path: misc.PathLike, options: {
|
|
39
38
|
bigint: true;
|
|
40
39
|
throwIfNoEntry: false;
|
|
41
40
|
}): misc.IStats<bigint> | undefined;
|
|
42
|
-
statSync(path: PathLike): misc.IStats<number>;
|
|
43
|
-
statSync(path: PathLike, options: {
|
|
41
|
+
statSync(path: misc.PathLike): misc.IStats<number>;
|
|
42
|
+
statSync(path: misc.PathLike, options: {
|
|
44
43
|
throwIfNoEntry?: true;
|
|
45
44
|
}): misc.IStats<number>;
|
|
46
|
-
statSync(path: PathLike, options: {
|
|
45
|
+
statSync(path: misc.PathLike, options: {
|
|
47
46
|
throwIfNoEntry: false;
|
|
48
47
|
}): misc.IStats<number> | undefined;
|
|
49
|
-
statSync(path: PathLike, options: {
|
|
48
|
+
statSync(path: misc.PathLike, options: {
|
|
50
49
|
bigint: false;
|
|
51
50
|
throwIfNoEntry?: true;
|
|
52
51
|
}): misc.IStats<number>;
|
|
53
|
-
statSync(path: PathLike, options: {
|
|
52
|
+
statSync(path: misc.PathLike, options: {
|
|
54
53
|
bigint: true;
|
|
55
54
|
throwIfNoEntry?: true;
|
|
56
55
|
}): misc.IStats<bigint>;
|
|
57
|
-
statSync(path: PathLike, options: {
|
|
56
|
+
statSync(path: misc.PathLike, options: {
|
|
58
57
|
bigint: false;
|
|
59
58
|
throwIfNoEntry: false;
|
|
60
59
|
}): misc.IStats<number> | undefined;
|
|
61
|
-
statSync(path: PathLike, options: {
|
|
60
|
+
statSync(path: misc.PathLike, options: {
|
|
62
61
|
bigint: true;
|
|
63
62
|
throwIfNoEntry: false;
|
|
64
63
|
}): misc.IStats<bigint> | undefined;
|
|
@@ -69,32 +68,32 @@ export interface FsSynchronousApi {
|
|
|
69
68
|
fstatSync(fd: number, options: {
|
|
70
69
|
bigint: true;
|
|
71
70
|
}): misc.IStats<bigint>;
|
|
72
|
-
renameSync(oldPath: PathLike, newPath: PathLike): void;
|
|
73
|
-
existsSync(path: PathLike): boolean;
|
|
74
|
-
accessSync(path: PathLike, mode?: number): void;
|
|
71
|
+
renameSync(oldPath: misc.PathLike, newPath: misc.PathLike): void;
|
|
72
|
+
existsSync(path: misc.PathLike): boolean;
|
|
73
|
+
accessSync(path: misc.PathLike, mode?: number): void;
|
|
75
74
|
appendFileSync(id: misc.TFileId, data: misc.TData, options?: opts.IAppendFileOptions | string): void;
|
|
76
|
-
readdirSync(path: PathLike, options?: opts.IReaddirOptions | string): misc.TDataOut[] | misc.IDirent[];
|
|
77
|
-
readlinkSync(path: PathLike, options?: opts.IOptions): misc.TDataOut;
|
|
75
|
+
readdirSync(path: misc.PathLike, options?: opts.IReaddirOptions | string): misc.TDataOut[] | misc.IDirent[];
|
|
76
|
+
readlinkSync(path: misc.PathLike, options?: opts.IOptions): misc.TDataOut;
|
|
77
|
+
fsyncSync(fd: number): void;
|
|
78
78
|
fdatasyncSync(fd: number): void;
|
|
79
79
|
ftruncateSync(fd: number, len?: number): void;
|
|
80
80
|
truncateSync(id: misc.TFileId, len?: number): void;
|
|
81
81
|
futimesSync(fd: number, atime: misc.TTime, mtime: misc.TTime): void;
|
|
82
|
-
utimesSync(path: PathLike, atime: misc.TTime, mtime: misc.TTime): void;
|
|
83
|
-
mkdirSync(path: PathLike, options: opts.IMkdirOptions & {
|
|
82
|
+
utimesSync(path: misc.PathLike, atime: misc.TTime, mtime: misc.TTime): void;
|
|
83
|
+
mkdirSync(path: misc.PathLike, options: opts.IMkdirOptions & {
|
|
84
84
|
recursive: true;
|
|
85
85
|
}): string | undefined;
|
|
86
|
-
mkdirSync(path: PathLike, options?: misc.TMode | (opts.IMkdirOptions & {
|
|
86
|
+
mkdirSync(path: misc.PathLike, options?: misc.TMode | (opts.IMkdirOptions & {
|
|
87
87
|
recursive?: false;
|
|
88
88
|
})): void;
|
|
89
|
-
mkdirSync(path: PathLike, options?: misc.TMode | opts.IMkdirOptions): string | undefined;
|
|
90
|
-
mkdirpSync(path: PathLike, mode?: misc.TMode): void;
|
|
89
|
+
mkdirSync(path: misc.PathLike, options?: misc.TMode | opts.IMkdirOptions): string | undefined;
|
|
91
90
|
mkdtempSync(prefix: string, options?: opts.IOptions): misc.TDataOut;
|
|
92
|
-
rmdirSync(path: PathLike, options?: opts.IRmdirOptions): void;
|
|
93
|
-
rmSync(path: PathLike, options?: opts.IRmOptions): void;
|
|
91
|
+
rmdirSync(path: misc.PathLike, options?: opts.IRmdirOptions): void;
|
|
92
|
+
rmSync(path: misc.PathLike, options?: opts.IRmOptions): void;
|
|
94
93
|
fchmodSync(fd: number, mode: misc.TMode): void;
|
|
95
|
-
chmodSync(path: PathLike, mode: misc.TMode): void;
|
|
96
|
-
lchmodSync(path: PathLike, mode: misc.TMode): void;
|
|
94
|
+
chmodSync(path: misc.PathLike, mode: misc.TMode): void;
|
|
95
|
+
lchmodSync(path: misc.PathLike, mode: misc.TMode): void;
|
|
97
96
|
fchownSync(fd: number, uid: number, gid: number): void;
|
|
98
|
-
chownSync(path: PathLike, uid: number, gid: number): void;
|
|
99
|
-
lchownSync(path: PathLike, uid: number, gid: number): void;
|
|
97
|
+
chownSync(path: misc.PathLike, uid: number, gid: number): void;
|
|
98
|
+
lchownSync(path: misc.PathLike, uid: number, gid: number): void;
|
|
100
99
|
}
|
|
@@ -1,83 +1,82 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import type { PathLike, symlink } from 'fs';
|
|
4
3
|
import type * as misc from './misc';
|
|
5
4
|
import type * as opts from './options';
|
|
6
5
|
export interface FsCallbackApi {
|
|
7
|
-
open(path: PathLike, flags: misc.TFlags,
|
|
8
|
-
open(path: PathLike, flags: misc.TFlags, mode: misc.TMode, callback: misc.TCallback<number>): any;
|
|
6
|
+
open(path: misc.PathLike, flags: misc.TFlags, callback: misc.TCallback<number>): any;
|
|
7
|
+
open(path: misc.PathLike, flags: misc.TFlags, mode: misc.TMode, callback: misc.TCallback<number>): any;
|
|
9
8
|
close(fd: number, callback: misc.TCallback<void>): void;
|
|
10
9
|
read(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, position: number, callback: (err?: Error | null, bytesRead?: number, buffer?: Buffer | ArrayBufferView | DataView) => void): void;
|
|
11
10
|
readFile(id: misc.TFileId, callback: misc.TCallback<misc.TDataOut>): any;
|
|
12
11
|
readFile(id: misc.TFileId, options: opts.IReadFileOptions | string, callback: misc.TCallback<misc.TDataOut>): any;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
unlink(path: PathLike, callback: misc.TCallback<void>): void;
|
|
26
|
-
symlink(target: PathLike, path: PathLike, callback: misc.TCallback<void>): any;
|
|
27
|
-
symlink(target: PathLike, path: PathLike, type: symlink.Type, callback: misc.TCallback<void>): any;
|
|
28
|
-
realpath(path: PathLike, callback: misc.TCallback<misc.TDataOut>): any;
|
|
29
|
-
realpath(path: PathLike, options: opts.IRealpathOptions | string, callback: misc.TCallback<misc.TDataOut>): any;
|
|
30
|
-
lstat(path: PathLike, callback: misc.TCallback<misc.IStats>): void;
|
|
31
|
-
lstat(path: PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStats>): void;
|
|
32
|
-
stat(path: PathLike, callback: misc.TCallback<misc.IStats>): void;
|
|
33
|
-
stat(path: PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStats>): void;
|
|
12
|
+
copyFile(src: misc.PathLike, dest: misc.PathLike, callback: misc.TCallback<void>): any;
|
|
13
|
+
copyFile(src: misc.PathLike, dest: misc.PathLike, flags: misc.TFlagsCopy, callback: misc.TCallback<void>): any;
|
|
14
|
+
link(existingPath: misc.PathLike, newPath: misc.PathLike, callback: misc.TCallback<void>): void;
|
|
15
|
+
unlink(path: misc.PathLike, callback: misc.TCallback<void>): void;
|
|
16
|
+
symlink(target: misc.PathLike, path: misc.PathLike, callback: misc.TCallback<void>): any;
|
|
17
|
+
symlink(target: misc.PathLike, path: misc.PathLike, type: misc.symlink.Type, callback: misc.TCallback<void>): any;
|
|
18
|
+
realpath(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut>): any;
|
|
19
|
+
realpath(path: misc.PathLike, options: opts.IRealpathOptions | string, callback: misc.TCallback<misc.TDataOut>): any;
|
|
20
|
+
lstat(path: misc.PathLike, callback: misc.TCallback<misc.IStats>): void;
|
|
21
|
+
lstat(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStats>): void;
|
|
22
|
+
stat(path: misc.PathLike, callback: misc.TCallback<misc.IStats>): void;
|
|
23
|
+
stat(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStats>): void;
|
|
34
24
|
fstat(fd: number, callback: misc.TCallback<misc.IStats>): void;
|
|
35
25
|
fstat(fd: number, options: opts.IFStatOptions, callback: misc.TCallback<misc.IStats>): void;
|
|
36
|
-
rename(oldPath: PathLike, newPath: PathLike, callback: misc.TCallback<void>): void;
|
|
37
|
-
exists(path: PathLike, callback: (exists: boolean) => void): void;
|
|
38
|
-
access(path: PathLike, callback: misc.TCallback<void>): any;
|
|
39
|
-
access(path: PathLike, mode: number, callback: misc.TCallback<void>): any;
|
|
26
|
+
rename(oldPath: misc.PathLike, newPath: misc.PathLike, callback: misc.TCallback<void>): void;
|
|
27
|
+
exists(path: misc.PathLike, callback: (exists: boolean) => void): void;
|
|
28
|
+
access(path: misc.PathLike, callback: misc.TCallback<void>): any;
|
|
29
|
+
access(path: misc.PathLike, mode: number, callback: misc.TCallback<void>): any;
|
|
40
30
|
appendFile(id: misc.TFileId, data: misc.TData, callback: misc.TCallback<void>): any;
|
|
41
31
|
appendFile(id: misc.TFileId, data: misc.TData, options: opts.IAppendFileOptions | string, callback: misc.TCallback<void>): any;
|
|
42
|
-
readdir(path: PathLike, callback: misc.TCallback<misc.TDataOut[] | misc.IDirent[]>): any;
|
|
43
|
-
readdir(path: PathLike, options: opts.IReaddirOptions | string, callback: misc.TCallback<misc.TDataOut[] | misc.IDirent[]>): any;
|
|
44
|
-
readlink(path: PathLike, callback: misc.TCallback<misc.TDataOut>): any;
|
|
45
|
-
readlink(path: PathLike, options: opts.IOptions, callback: misc.TCallback<misc.TDataOut>): any;
|
|
46
|
-
fsyncSync(fd: number): void;
|
|
32
|
+
readdir(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut[] | misc.IDirent[]>): any;
|
|
33
|
+
readdir(path: misc.PathLike, options: opts.IReaddirOptions | string, callback: misc.TCallback<misc.TDataOut[] | misc.IDirent[]>): any;
|
|
34
|
+
readlink(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut>): any;
|
|
35
|
+
readlink(path: misc.PathLike, options: opts.IOptions, callback: misc.TCallback<misc.TDataOut>): any;
|
|
47
36
|
fsync(fd: number, callback: misc.TCallback<void>): void;
|
|
48
37
|
fdatasync(fd: number, callback: misc.TCallback<void>): void;
|
|
49
38
|
ftruncate(fd: number, callback: misc.TCallback<void>): any;
|
|
50
39
|
ftruncate(fd: number, len: number, callback: misc.TCallback<void>): any;
|
|
51
|
-
truncate(id: misc.
|
|
52
|
-
truncate(id: misc.
|
|
40
|
+
truncate(id: misc.PathLike, callback: misc.TCallback<void>): any;
|
|
41
|
+
truncate(id: misc.PathLike, len: number, callback: misc.TCallback<void>): any;
|
|
53
42
|
futimes(fd: number, atime: misc.TTime, mtime: misc.TTime, callback: misc.TCallback<void>): void;
|
|
54
|
-
utimes(path: PathLike, atime: misc.TTime, mtime: misc.TTime, callback: misc.TCallback<void>): void;
|
|
55
|
-
mkdir(path: PathLike, callback: misc.TCallback<void>): any;
|
|
56
|
-
mkdir(path: PathLike, mode: misc.TMode | (opts.IMkdirOptions & {
|
|
43
|
+
utimes(path: misc.PathLike, atime: misc.TTime, mtime: misc.TTime, callback: misc.TCallback<void>): void;
|
|
44
|
+
mkdir(path: misc.PathLike, callback: misc.TCallback<void>): any;
|
|
45
|
+
mkdir(path: misc.PathLike, mode: misc.TMode | (opts.IMkdirOptions & {
|
|
57
46
|
recursive?: false;
|
|
58
47
|
}), callback: misc.TCallback<void>): any;
|
|
59
|
-
mkdir(path: PathLike, mode: opts.IMkdirOptions & {
|
|
48
|
+
mkdir(path: misc.PathLike, mode: opts.IMkdirOptions & {
|
|
60
49
|
recursive: true;
|
|
61
50
|
}, callback: misc.TCallback<string>): any;
|
|
62
|
-
mkdir(path: PathLike, mode: misc.TMode | opts.IMkdirOptions, callback: misc.TCallback<string>): any;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
rm(path: PathLike, callback: misc.TCallback<void>): void;
|
|
70
|
-
rm(path: PathLike, options: opts.IRmOptions, callback: misc.TCallback<void>): void;
|
|
51
|
+
mkdir(path: misc.PathLike, mode: misc.TMode | opts.IMkdirOptions, callback: misc.TCallback<string>): any;
|
|
52
|
+
mkdtemp(prefix: string, callback: misc.TCallback<string>): void;
|
|
53
|
+
mkdtemp(prefix: string, options: opts.IOptions, callback: misc.TCallback<string>): any;
|
|
54
|
+
rmdir(path: misc.PathLike, callback: misc.TCallback<void>): any;
|
|
55
|
+
rmdir(path: misc.PathLike, options: opts.IRmdirOptions, callback: misc.TCallback<void>): any;
|
|
56
|
+
rm(path: misc.PathLike, callback: misc.TCallback<void>): void;
|
|
57
|
+
rm(path: misc.PathLike, options: opts.IRmOptions, callback: misc.TCallback<void>): void;
|
|
71
58
|
fchmod(fd: number, mode: misc.TMode, callback: misc.TCallback<void>): void;
|
|
72
|
-
chmod(path: PathLike, mode: misc.TMode, callback: misc.TCallback<void>): void;
|
|
73
|
-
lchmod(path: PathLike, mode: misc.TMode, callback: misc.TCallback<void>): void;
|
|
59
|
+
chmod(path: misc.PathLike, mode: misc.TMode, callback: misc.TCallback<void>): void;
|
|
60
|
+
lchmod(path: misc.PathLike, mode: misc.TMode, callback: misc.TCallback<void>): void;
|
|
74
61
|
fchown(fd: number, uid: number, gid: number, callback: misc.TCallback<void>): void;
|
|
75
|
-
chown(path: PathLike, uid: number, gid: number, callback: misc.TCallback<void>): void;
|
|
76
|
-
lchown(path: PathLike, uid: number, gid: number, callback: misc.TCallback<void>): void;
|
|
77
|
-
watchFile(path: PathLike, listener: (curr: misc.IStats, prev: misc.IStats) => void): misc.IStatWatcher;
|
|
78
|
-
watchFile(path: PathLike, options: opts.IWatchFileOptions, listener: (curr: misc.IStats, prev: misc.IStats) => void): misc.IStatWatcher;
|
|
79
|
-
unwatchFile(path: PathLike, listener?: (curr: misc.IStats, prev: misc.IStats) => void): void;
|
|
80
|
-
createReadStream(path: PathLike, options?: opts.IReadStreamOptions | string): misc.IReadStream;
|
|
81
|
-
createWriteStream(path: PathLike, options?: opts.IWriteStreamOptions | string): misc.IWriteStream;
|
|
82
|
-
watch(path: PathLike, options?: opts.IWatchOptions | string, listener?: (eventType: string, filename: string) => void): misc.IFSWatcher;
|
|
62
|
+
chown(path: misc.PathLike, uid: number, gid: number, callback: misc.TCallback<void>): void;
|
|
63
|
+
lchown(path: misc.PathLike, uid: number, gid: number, callback: misc.TCallback<void>): void;
|
|
64
|
+
watchFile(path: misc.PathLike, listener: (curr: misc.IStats, prev: misc.IStats) => void): misc.IStatWatcher;
|
|
65
|
+
watchFile(path: misc.PathLike, options: opts.IWatchFileOptions, listener: (curr: misc.IStats, prev: misc.IStats) => void): misc.IStatWatcher;
|
|
66
|
+
unwatchFile(path: misc.PathLike, listener?: (curr: misc.IStats, prev: misc.IStats) => void): void;
|
|
67
|
+
createReadStream(path: misc.PathLike, options?: opts.IReadStreamOptions | string): misc.IReadStream;
|
|
68
|
+
createWriteStream(path: misc.PathLike, options?: opts.IWriteStreamOptions | string): misc.IWriteStream;
|
|
69
|
+
watch(path: misc.PathLike, options?: opts.IWatchOptions | string, listener?: (eventType: string, filename: string) => void): misc.IFSWatcher;
|
|
70
|
+
write(fd: number, buffer: Buffer | ArrayBufferView | DataView, callback: (...args: any[]) => void): any;
|
|
71
|
+
write(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, callback: (...args: any[]) => void): any;
|
|
72
|
+
write(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, callback: (...args: any[]) => void): any;
|
|
73
|
+
write(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, position: number, callback: (...args: any[]) => void): any;
|
|
74
|
+
write(fd: number, str: string, callback: (...args: any[]) => void): any;
|
|
75
|
+
write(fd: number, str: string, position: number, callback: (...args: any[]) => void): any;
|
|
76
|
+
write(fd: number, str: string, position: number, encoding: BufferEncoding, callback: (...args: any[]) => void): any;
|
|
77
|
+
writeFile(id: misc.TFileId, data: misc.TData, callback: misc.TCallback<void>): any;
|
|
78
|
+
writeFile(id: misc.TFileId, data: misc.TData, options: opts.IWriteFileOptions | string, callback: misc.TCallback<void>): any;
|
|
79
|
+
writev(fd: number, buffers: ArrayBufferView[], callback: WritevCallback): void;
|
|
80
|
+
writev(fd: number, buffers: ArrayBufferView[], position: number | null, callback: WritevCallback): void;
|
|
83
81
|
}
|
|
82
|
+
export type WritevCallback = (err: Error | null, bytesWritten?: number, buffers?: ArrayBufferView[]) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FsSynchronousApi } from './
|
|
1
|
+
import type { FsSynchronousApi } from './FsSynchronousApi';
|
|
2
2
|
import type { FsCallbackApi } from './callback';
|
|
3
3
|
import type { FsPromisesApi } from './promises';
|
|
4
4
|
export { FsSynchronousApi, FsCallbackApi, FsPromisesApi };
|
package/lib/node/types/misc.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { PathLike, symlink } from 'fs';
|
|
|
6
6
|
import type { constants } from '../../constants';
|
|
7
7
|
import type { EventEmitter } from 'events';
|
|
8
8
|
import type { TSetTimeout } from '../../setTimeoutUnref';
|
|
9
|
-
import type { IAppendFileOptions, IReadFileOptions,
|
|
9
|
+
import type { IAppendFileOptions, IReadFileOptions, IStatOptions, IWriteFileOptions } from './options';
|
|
10
10
|
import type { Readable, Writable } from 'stream';
|
|
11
11
|
export { PathLike, symlink };
|
|
12
12
|
export type TDataOut = string | Buffer;
|
|
@@ -69,18 +69,15 @@ export interface IStatWatcher extends EventEmitter {
|
|
|
69
69
|
stop(): void;
|
|
70
70
|
}
|
|
71
71
|
export interface IReadStream extends Readable {
|
|
72
|
-
new (path: PathLike, options: IReadStreamOptions): any;
|
|
73
|
-
open(): any;
|
|
74
|
-
close(callback: TCallback<void>): any;
|
|
75
72
|
bytesRead: number;
|
|
76
|
-
path: string;
|
|
73
|
+
path: string | Buffer;
|
|
74
|
+
pending: boolean;
|
|
77
75
|
}
|
|
78
76
|
export interface IWriteStream extends Writable {
|
|
79
77
|
bytesWritten: number;
|
|
80
78
|
path: string;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
close(): any;
|
|
79
|
+
pending: boolean;
|
|
80
|
+
close(callback?: (err?: Error) => void): void;
|
|
84
81
|
}
|
|
85
82
|
export interface IFSWatcher extends EventEmitter {
|
|
86
83
|
start(path: PathLike, persistent?: boolean, recursive?: boolean, encoding?: BufferEncoding): void;
|
|
@@ -110,3 +107,4 @@ export interface TFileHandleWriteResult {
|
|
|
110
107
|
bytesWritten: number;
|
|
111
108
|
buffer: Buffer | Uint8Array;
|
|
112
109
|
}
|
|
110
|
+
export type AssertCallback<T> = T extends () => void ? T : never;
|