memfs 3.6.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 +82 -0
- package/lib/fsa/types.js +2 -0
- 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,12 @@
|
|
|
1
|
+
import type { IFs } from '..';
|
|
2
|
+
/**
|
|
3
|
+
* Required Node.js `fs` module functions for File System Access API.
|
|
4
|
+
*/
|
|
5
|
+
export type NodeFsaFs = Pick<IFs, 'promises' | 'constants' | 'openSync' | 'fsyncSync' | 'statSync' | 'closeSync' | 'readSync' | 'truncateSync' | 'writeSync'>;
|
|
6
|
+
export interface NodeFsaContext {
|
|
7
|
+
separator: '/' | '\\';
|
|
8
|
+
/** Whether synchronous file handles are allowed. */
|
|
9
|
+
syncHandleAllowed: boolean;
|
|
10
|
+
/** Whether writes are allowed, defaults to `read`. */
|
|
11
|
+
mode: 'read' | 'readwrite';
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { NodeFsaContext } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new {@link NodeFsaContext}.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ctx: (partial?: Partial<NodeFsaContext>) => NodeFsaContext;
|
|
6
|
+
export declare const basename: (path: string, separator: string) => string;
|
|
7
|
+
export declare const assertName: (name: string, method: string, klass: string) => void;
|
|
8
|
+
export declare const assertCanWrite: (mode: 'read' | 'readwrite') => void;
|
|
9
|
+
export declare const newNotFoundError: () => DOMException;
|
|
10
|
+
export declare const newTypeMismatchError: () => DOMException;
|
|
11
|
+
export declare const newNotAllowedError: () => DOMException;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newNotAllowedError = exports.newTypeMismatchError = exports.newNotFoundError = exports.assertCanWrite = exports.assertName = exports.basename = exports.ctx = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new {@link NodeFsaContext}.
|
|
6
|
+
*/
|
|
7
|
+
const ctx = (partial = {}) => {
|
|
8
|
+
return Object.assign({ separator: '/', syncHandleAllowed: false, mode: 'read' }, partial);
|
|
9
|
+
};
|
|
10
|
+
exports.ctx = ctx;
|
|
11
|
+
const basename = (path, separator) => {
|
|
12
|
+
const lastSlashIndex = path.lastIndexOf(separator);
|
|
13
|
+
return lastSlashIndex === -1 ? path : path.slice(lastSlashIndex + 1);
|
|
14
|
+
};
|
|
15
|
+
exports.basename = basename;
|
|
16
|
+
const nameRegex = /^(\.{1,2})|(.*(\/|\\).*)$/;
|
|
17
|
+
const assertName = (name, method, klass) => {
|
|
18
|
+
const isInvalid = !name || nameRegex.test(name);
|
|
19
|
+
if (isInvalid)
|
|
20
|
+
throw new TypeError(`Failed to execute '${method}' on '${klass}': Name is not allowed.`);
|
|
21
|
+
};
|
|
22
|
+
exports.assertName = assertName;
|
|
23
|
+
const assertCanWrite = (mode) => {
|
|
24
|
+
if (mode !== 'readwrite')
|
|
25
|
+
throw new DOMException('The request is not allowed by the user agent or the platform in the current context.', 'NotAllowedError');
|
|
26
|
+
};
|
|
27
|
+
exports.assertCanWrite = assertCanWrite;
|
|
28
|
+
const newNotFoundError = () => new DOMException('A requested file or directory could not be found at the time an operation was processed.', 'NotFoundError');
|
|
29
|
+
exports.newNotFoundError = newNotFoundError;
|
|
30
|
+
const newTypeMismatchError = () => new DOMException('The path supplied exists, but was not an entry of requested type.', 'TypeMismatchError');
|
|
31
|
+
exports.newTypeMismatchError = newTypeMismatchError;
|
|
32
|
+
const newNotAllowedError = () => new DOMException('Permission not granted.', 'NotAllowedError');
|
|
33
|
+
exports.newNotAllowedError = newNotAllowedError;
|
package/lib/node.d.ts
CHANGED
|
@@ -149,7 +149,7 @@ export declare class File {
|
|
|
149
149
|
truncate(len?: number): void;
|
|
150
150
|
seekTo(position: number): void;
|
|
151
151
|
stats(): Stats<number>;
|
|
152
|
-
write(buf: Buffer, offset?: number, length?: number, position?: number): number;
|
|
152
|
+
write(buf: Buffer, offset?: number, length?: number, position?: number | null): number;
|
|
153
153
|
read(buf: Buffer | ArrayBufferView | DataView, offset?: number, length?: number, position?: number): number;
|
|
154
154
|
chmod(perm: number): void;
|
|
155
155
|
chown(uid: number, gid: number): void;
|
package/lib/volume.d.ts
CHANGED
|
@@ -6,11 +6,14 @@ import { Node, Link, File } from './node';
|
|
|
6
6
|
import Stats from './Stats';
|
|
7
7
|
import Dirent from './Dirent';
|
|
8
8
|
import { TSetTimeout } from './setTimeoutUnref';
|
|
9
|
-
import {
|
|
9
|
+
import { Writable } from 'stream';
|
|
10
10
|
import { constants } from './constants';
|
|
11
11
|
import { EventEmitter } from 'events';
|
|
12
|
-
import {
|
|
12
|
+
import { TDataOut } from './encoding';
|
|
13
|
+
import * as misc from './node/types/misc';
|
|
14
|
+
import * as opts from './node/types/options';
|
|
13
15
|
import type { PathLike, symlink } from 'fs';
|
|
16
|
+
import { FsCallbackApi, WritevCallback } from './node/types/callback';
|
|
14
17
|
export interface IError extends Error {
|
|
15
18
|
code?: string;
|
|
16
19
|
}
|
|
@@ -20,102 +23,20 @@ export type TFlags = string | number;
|
|
|
20
23
|
export type TMode = string | number;
|
|
21
24
|
export type TTime = number | string | Date;
|
|
22
25
|
export type TCallback<TData> = (error?: IError | null, data?: TData) => void;
|
|
23
|
-
export declare enum FLAGS {
|
|
24
|
-
r,
|
|
25
|
-
'r+',
|
|
26
|
-
rs,
|
|
27
|
-
sr,
|
|
28
|
-
'rs+',
|
|
29
|
-
'sr+',
|
|
30
|
-
w,
|
|
31
|
-
wx,
|
|
32
|
-
xw,
|
|
33
|
-
'w+',
|
|
34
|
-
'wx+',
|
|
35
|
-
'xw+',
|
|
36
|
-
a,
|
|
37
|
-
ax,
|
|
38
|
-
xa,
|
|
39
|
-
'a+',
|
|
40
|
-
'ax+',
|
|
41
|
-
'xa+'
|
|
42
|
-
}
|
|
43
26
|
export type TFlagsCopy = typeof constants.COPYFILE_EXCL | typeof constants.COPYFILE_FICLONE | typeof constants.COPYFILE_FICLONE_FORCE;
|
|
44
|
-
export
|
|
45
|
-
export interface IOptions {
|
|
46
|
-
encoding?: BufferEncoding | TEncodingExtended;
|
|
47
|
-
}
|
|
48
|
-
export interface IFileOptions extends IOptions {
|
|
49
|
-
mode?: TMode;
|
|
50
|
-
flag?: TFlags;
|
|
51
|
-
}
|
|
52
|
-
export interface IReadFileOptions extends IOptions {
|
|
53
|
-
flag?: string;
|
|
54
|
-
}
|
|
55
|
-
export interface IWriteFileOptions extends IFileOptions {
|
|
56
|
-
}
|
|
57
|
-
export interface IAppendFileOptions extends IFileOptions {
|
|
58
|
-
}
|
|
59
|
-
export interface IRealpathOptions {
|
|
60
|
-
encoding?: TEncodingExtended;
|
|
27
|
+
export interface IAppendFileOptions extends opts.IFileOptions {
|
|
61
28
|
}
|
|
62
29
|
export interface IWatchFileOptions {
|
|
63
30
|
persistent?: boolean;
|
|
64
31
|
interval?: number;
|
|
65
32
|
}
|
|
66
|
-
export interface
|
|
67
|
-
flags?: TFlags;
|
|
68
|
-
encoding?: BufferEncoding;
|
|
69
|
-
fd?: number;
|
|
70
|
-
mode?: TMode;
|
|
71
|
-
autoClose?: boolean;
|
|
72
|
-
start?: number;
|
|
73
|
-
end?: number;
|
|
74
|
-
}
|
|
75
|
-
export interface IWriteStreamOptions {
|
|
76
|
-
flags?: TFlags;
|
|
77
|
-
defaultEncoding?: BufferEncoding;
|
|
78
|
-
fd?: number;
|
|
79
|
-
mode?: TMode;
|
|
80
|
-
autoClose?: boolean;
|
|
81
|
-
start?: number;
|
|
82
|
-
}
|
|
83
|
-
export interface IWatchOptions extends IOptions {
|
|
33
|
+
export interface IWatchOptions extends opts.IOptions {
|
|
84
34
|
persistent?: boolean;
|
|
85
35
|
recursive?: boolean;
|
|
86
36
|
}
|
|
87
|
-
export interface IMkdirOptions {
|
|
88
|
-
mode?: TMode;
|
|
89
|
-
recursive?: boolean;
|
|
90
|
-
}
|
|
91
|
-
export interface IRmdirOptions {
|
|
92
|
-
/** @deprecated */
|
|
93
|
-
recursive?: boolean;
|
|
94
|
-
maxRetries?: number;
|
|
95
|
-
retryDelay?: number;
|
|
96
|
-
}
|
|
97
|
-
export interface IRmOptions {
|
|
98
|
-
force?: boolean;
|
|
99
|
-
maxRetries?: number;
|
|
100
|
-
recursive?: boolean;
|
|
101
|
-
retryDelay?: number;
|
|
102
|
-
}
|
|
103
|
-
export interface IReaddirOptions extends IOptions {
|
|
104
|
-
withFileTypes?: boolean;
|
|
105
|
-
}
|
|
106
|
-
export interface IStatOptions {
|
|
107
|
-
bigint?: boolean;
|
|
108
|
-
throwIfNoEntry?: boolean;
|
|
109
|
-
}
|
|
110
|
-
export interface IFStatOptions {
|
|
111
|
-
bigint?: boolean;
|
|
112
|
-
}
|
|
113
|
-
export declare function pathToFilename(path: PathLike): string;
|
|
114
37
|
export declare function filenameToSteps(filename: string, base?: string): string[];
|
|
115
38
|
export declare function pathToSteps(path: PathLike): string[];
|
|
116
39
|
export declare function dataToStr(data: TData, encoding?: string): string;
|
|
117
|
-
export declare function dataToBuffer(data: TData, encoding?: string): Buffer;
|
|
118
|
-
export declare function bufferToEncoding(buffer: Buffer, encoding?: TEncodingExtended): TDataOut;
|
|
119
40
|
export declare function toUnixTimestamp(time: any): any;
|
|
120
41
|
type DirectoryContent = string | null;
|
|
121
42
|
export interface DirectoryJSON {
|
|
@@ -127,7 +48,7 @@ export interface NestedDirectoryJSON {
|
|
|
127
48
|
/**
|
|
128
49
|
* `Volume` represents a file system.
|
|
129
50
|
*/
|
|
130
|
-
export declare class Volume {
|
|
51
|
+
export declare class Volume implements FsCallbackApi {
|
|
131
52
|
static fromJSON(json: DirectoryJSON, cwd?: string): Volume;
|
|
132
53
|
static fromNestedJSON(json: NestedDirectoryJSON, cwd?: string): Volume;
|
|
133
54
|
/**
|
|
@@ -151,7 +72,7 @@ export declare class Volume {
|
|
|
151
72
|
maxFiles: number;
|
|
152
73
|
openFiles: number;
|
|
153
74
|
StatWatcher: new () => StatWatcher;
|
|
154
|
-
ReadStream: new (...args: any[]) => IReadStream;
|
|
75
|
+
ReadStream: new (...args: any[]) => misc.IReadStream;
|
|
155
76
|
WriteStream: new (...args: any[]) => IWriteStream;
|
|
156
77
|
FSWatcher: new () => FSWatcher;
|
|
157
78
|
props: {
|
|
@@ -168,9 +89,7 @@ export declare class Volume {
|
|
|
168
89
|
private newInoNumber;
|
|
169
90
|
private newFdNumber;
|
|
170
91
|
createNode(isDirectory?: boolean, perm?: number): Node;
|
|
171
|
-
private getNode;
|
|
172
92
|
private deleteNode;
|
|
173
|
-
genRndStr(): any;
|
|
174
93
|
getLink(steps: string[]): Link | null;
|
|
175
94
|
getLinkOrThrow(filename: string, funcName?: string): Link;
|
|
176
95
|
getResolvedLink(filenameOrSteps: string | string[]): Link | null;
|
|
@@ -205,9 +124,9 @@ export declare class Volume {
|
|
|
205
124
|
readSync(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, position: number): number;
|
|
206
125
|
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;
|
|
207
126
|
private readFileBase;
|
|
208
|
-
readFileSync(file: TFileId, options?: IReadFileOptions | string): TDataOut;
|
|
127
|
+
readFileSync(file: TFileId, options?: opts.IReadFileOptions | string): TDataOut;
|
|
209
128
|
readFile(id: TFileId, callback: TCallback<TDataOut>): any;
|
|
210
|
-
readFile(id: TFileId, options: IReadFileOptions | string, callback: TCallback<TDataOut>): any;
|
|
129
|
+
readFile(id: TFileId, options: opts.IReadFileOptions | string, callback: TCallback<TDataOut>): any;
|
|
211
130
|
private writeBase;
|
|
212
131
|
writeSync(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset?: number, length?: number, position?: number): number;
|
|
213
132
|
writeSync(fd: number, str: string, position?: number, encoding?: BufferEncoding): number;
|
|
@@ -218,10 +137,12 @@ export declare class Volume {
|
|
|
218
137
|
write(fd: number, str: string, callback: (...args: any[]) => void): any;
|
|
219
138
|
write(fd: number, str: string, position: number, callback: (...args: any[]) => void): any;
|
|
220
139
|
write(fd: number, str: string, position: number, encoding: BufferEncoding, callback: (...args: any[]) => void): any;
|
|
140
|
+
writev(fd: number, buffers: ArrayBufferView[], callback: WritevCallback): void;
|
|
141
|
+
writev(fd: number, buffers: ArrayBufferView[], position: number | null, callback: WritevCallback): void;
|
|
221
142
|
private writeFileBase;
|
|
222
|
-
writeFileSync(id: TFileId, data: TData, options?: IWriteFileOptions): void;
|
|
143
|
+
writeFileSync(id: TFileId, data: TData, options?: opts.IWriteFileOptions): void;
|
|
223
144
|
writeFile(id: TFileId, data: TData, callback: TCallback<void>): any;
|
|
224
|
-
writeFile(id: TFileId, data: TData, options: IWriteFileOptions | string, callback: TCallback<void>): any;
|
|
145
|
+
writeFile(id: TFileId, data: TData, options: opts.IWriteFileOptions | string, callback: TCallback<void>): any;
|
|
225
146
|
private linkBase;
|
|
226
147
|
private copyFileBase;
|
|
227
148
|
copyFileSync(src: PathLike, dest: PathLike, flags?: TFlagsCopy): void;
|
|
@@ -237,9 +158,9 @@ export declare class Volume {
|
|
|
237
158
|
symlink(target: PathLike, path: PathLike, callback: TCallback<void>): any;
|
|
238
159
|
symlink(target: PathLike, path: PathLike, type: symlink.Type, callback: TCallback<void>): any;
|
|
239
160
|
private realpathBase;
|
|
240
|
-
realpathSync(path: PathLike, options?: IRealpathOptions | string): TDataOut;
|
|
161
|
+
realpathSync(path: PathLike, options?: opts.IRealpathOptions | string): TDataOut;
|
|
241
162
|
realpath(path: PathLike, callback: TCallback<TDataOut>): any;
|
|
242
|
-
realpath(path: PathLike, options: IRealpathOptions | string, callback: TCallback<TDataOut>): any;
|
|
163
|
+
realpath(path: PathLike, options: opts.IRealpathOptions | string, callback: TCallback<TDataOut>): any;
|
|
243
164
|
private lstatBase;
|
|
244
165
|
lstatSync(path: PathLike): Stats<number>;
|
|
245
166
|
lstatSync(path: PathLike, options: {
|
|
@@ -265,7 +186,7 @@ export declare class Volume {
|
|
|
265
186
|
throwIfNoEntry: false;
|
|
266
187
|
}): Stats<bigint> | undefined;
|
|
267
188
|
lstat(path: PathLike, callback: TCallback<Stats>): void;
|
|
268
|
-
lstat(path: PathLike, options: IStatOptions, callback: TCallback<Stats>): void;
|
|
189
|
+
lstat(path: PathLike, options: opts.IStatOptions, callback: TCallback<Stats>): void;
|
|
269
190
|
private statBase;
|
|
270
191
|
statSync(path: PathLike): Stats<number>;
|
|
271
192
|
statSync(path: PathLike, options: {
|
|
@@ -291,7 +212,7 @@ export declare class Volume {
|
|
|
291
212
|
throwIfNoEntry: false;
|
|
292
213
|
}): Stats<bigint> | undefined;
|
|
293
214
|
stat(path: PathLike, callback: TCallback<Stats>): void;
|
|
294
|
-
stat(path: PathLike, options: IStatOptions, callback: TCallback<Stats>): void;
|
|
215
|
+
stat(path: PathLike, options: opts.IStatOptions, callback: TCallback<Stats>): void;
|
|
295
216
|
private fstatBase;
|
|
296
217
|
fstatSync(fd: number): Stats<number>;
|
|
297
218
|
fstatSync(fd: number, options: {
|
|
@@ -301,7 +222,7 @@ export declare class Volume {
|
|
|
301
222
|
bigint: true;
|
|
302
223
|
}): Stats<bigint>;
|
|
303
224
|
fstat(fd: number, callback: TCallback<Stats>): void;
|
|
304
|
-
fstat(fd: number, options: IFStatOptions, callback: TCallback<Stats>): void;
|
|
225
|
+
fstat(fd: number, options: opts.IFStatOptions, callback: TCallback<Stats>): void;
|
|
305
226
|
private renameBase;
|
|
306
227
|
renameSync(oldPath: PathLike, newPath: PathLike): void;
|
|
307
228
|
rename(oldPath: PathLike, newPath: PathLike, callback: TCallback<void>): void;
|
|
@@ -316,13 +237,13 @@ export declare class Volume {
|
|
|
316
237
|
appendFile(id: TFileId, data: TData, callback: TCallback<void>): any;
|
|
317
238
|
appendFile(id: TFileId, data: TData, options: IAppendFileOptions | string, callback: TCallback<void>): any;
|
|
318
239
|
private readdirBase;
|
|
319
|
-
readdirSync(path: PathLike, options?: IReaddirOptions | string): TDataOut[] | Dirent[];
|
|
240
|
+
readdirSync(path: PathLike, options?: opts.IReaddirOptions | string): TDataOut[] | Dirent[];
|
|
320
241
|
readdir(path: PathLike, callback: TCallback<TDataOut[] | Dirent[]>): any;
|
|
321
|
-
readdir(path: PathLike, options: IReaddirOptions | string, callback: TCallback<TDataOut[] | Dirent[]>): any;
|
|
242
|
+
readdir(path: PathLike, options: opts.IReaddirOptions | string, callback: TCallback<TDataOut[] | Dirent[]>): any;
|
|
322
243
|
private readlinkBase;
|
|
323
|
-
readlinkSync(path: PathLike, options?: IOptions): TDataOut;
|
|
244
|
+
readlinkSync(path: PathLike, options?: opts.IOptions): TDataOut;
|
|
324
245
|
readlink(path: PathLike, callback: TCallback<TDataOut>): any;
|
|
325
|
-
readlink(path: PathLike, options: IOptions, callback: TCallback<TDataOut>): any;
|
|
246
|
+
readlink(path: PathLike, options: opts.IOptions, callback: TCallback<TDataOut>): any;
|
|
326
247
|
private fsyncBase;
|
|
327
248
|
fsyncSync(fd: number): void;
|
|
328
249
|
fsync(fd: number, callback: TCallback<void>): void;
|
|
@@ -334,6 +255,10 @@ export declare class Volume {
|
|
|
334
255
|
ftruncate(fd: number, callback: TCallback<void>): any;
|
|
335
256
|
ftruncate(fd: number, len: number, callback: TCallback<void>): any;
|
|
336
257
|
private truncateBase;
|
|
258
|
+
/**
|
|
259
|
+
* `id` should be a file descriptor or a path. `id` as file descriptor will
|
|
260
|
+
* not be supported soon.
|
|
261
|
+
*/
|
|
337
262
|
truncateSync(id: TFileId, len?: number): void;
|
|
338
263
|
truncate(id: TFileId, callback: TCallback<void>): any;
|
|
339
264
|
truncate(id: TFileId, len: number, callback: TCallback<void>): any;
|
|
@@ -350,36 +275,36 @@ export declare class Volume {
|
|
|
350
275
|
* @param modeNum
|
|
351
276
|
*/
|
|
352
277
|
private mkdirpBase;
|
|
353
|
-
mkdirSync(path: PathLike, options: IMkdirOptions & {
|
|
278
|
+
mkdirSync(path: PathLike, options: opts.IMkdirOptions & {
|
|
354
279
|
recursive: true;
|
|
355
280
|
}): string | undefined;
|
|
356
|
-
mkdirSync(path: PathLike, options?: TMode | (IMkdirOptions & {
|
|
281
|
+
mkdirSync(path: PathLike, options?: TMode | (opts.IMkdirOptions & {
|
|
357
282
|
recursive?: false;
|
|
358
283
|
})): void;
|
|
359
|
-
mkdirSync(path: PathLike, options?: TMode | IMkdirOptions): string | undefined;
|
|
284
|
+
mkdirSync(path: PathLike, options?: TMode | opts.IMkdirOptions): string | undefined;
|
|
360
285
|
mkdir(path: PathLike, callback: TCallback<void>): any;
|
|
361
|
-
mkdir(path: PathLike, mode: TMode | (IMkdirOptions & {
|
|
286
|
+
mkdir(path: PathLike, mode: TMode | (opts.IMkdirOptions & {
|
|
362
287
|
recursive?: false;
|
|
363
288
|
}), callback: TCallback<void>): any;
|
|
364
|
-
mkdir(path: PathLike, mode: IMkdirOptions & {
|
|
289
|
+
mkdir(path: PathLike, mode: opts.IMkdirOptions & {
|
|
365
290
|
recursive: true;
|
|
366
291
|
}, callback: TCallback<string>): any;
|
|
367
|
-
mkdir(path: PathLike, mode: TMode | IMkdirOptions, callback: TCallback<string>): any;
|
|
292
|
+
mkdir(path: PathLike, mode: TMode | opts.IMkdirOptions, callback: TCallback<string>): any;
|
|
368
293
|
mkdirpSync(path: PathLike, mode?: TMode): string | undefined;
|
|
369
294
|
mkdirp(path: PathLike, callback: TCallback<string>): any;
|
|
370
295
|
mkdirp(path: PathLike, mode: TMode, callback: TCallback<string>): any;
|
|
371
296
|
private mkdtempBase;
|
|
372
|
-
mkdtempSync(prefix: string, options?: IOptions): TDataOut;
|
|
373
|
-
mkdtemp(prefix: string, callback: TCallback<
|
|
374
|
-
mkdtemp(prefix: string, options: IOptions, callback: TCallback<
|
|
297
|
+
mkdtempSync(prefix: string, options?: opts.IOptions): TDataOut;
|
|
298
|
+
mkdtemp(prefix: string, callback: TCallback<string>): any;
|
|
299
|
+
mkdtemp(prefix: string, options: opts.IOptions, callback: TCallback<string>): any;
|
|
375
300
|
private rmdirBase;
|
|
376
|
-
rmdirSync(path: PathLike, options?: IRmdirOptions): void;
|
|
301
|
+
rmdirSync(path: PathLike, options?: opts.IRmdirOptions): void;
|
|
377
302
|
rmdir(path: PathLike, callback: TCallback<void>): any;
|
|
378
|
-
rmdir(path: PathLike, options: IRmdirOptions, callback: TCallback<void>): any;
|
|
303
|
+
rmdir(path: PathLike, options: opts.IRmdirOptions, callback: TCallback<void>): any;
|
|
379
304
|
private rmBase;
|
|
380
|
-
rmSync(path: PathLike, options?: IRmOptions): void;
|
|
305
|
+
rmSync(path: PathLike, options?: opts.IRmOptions): void;
|
|
381
306
|
rm(path: PathLike, callback: TCallback<void>): void;
|
|
382
|
-
rm(path: PathLike, options: IRmOptions, callback: TCallback<void>): void;
|
|
307
|
+
rm(path: PathLike, options: opts.IRmOptions, callback: TCallback<void>): void;
|
|
383
308
|
private fchmodBase;
|
|
384
309
|
fchmodSync(fd: number, mode: TMode): void;
|
|
385
310
|
fchmod(fd: number, mode: TMode, callback: TCallback<void>): void;
|
|
@@ -402,8 +327,8 @@ export declare class Volume {
|
|
|
402
327
|
watchFile(path: PathLike, listener: (curr: Stats, prev: Stats) => void): StatWatcher;
|
|
403
328
|
watchFile(path: PathLike, options: IWatchFileOptions, listener: (curr: Stats, prev: Stats) => void): StatWatcher;
|
|
404
329
|
unwatchFile(path: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
|
|
405
|
-
createReadStream(path: PathLike, options?: IReadStreamOptions | string): IReadStream;
|
|
406
|
-
createWriteStream(path: PathLike, options?: IWriteStreamOptions | string): IWriteStream;
|
|
330
|
+
createReadStream(path: misc.PathLike, options?: opts.IReadStreamOptions | string): misc.IReadStream;
|
|
331
|
+
createWriteStream(path: PathLike, options?: opts.IWriteStreamOptions | string): IWriteStream;
|
|
407
332
|
watch(path: PathLike, options?: IWatchOptions | string, listener?: (eventType: string, filename: string) => void): FSWatcher;
|
|
408
333
|
}
|
|
409
334
|
export declare class StatWatcher extends EventEmitter {
|
|
@@ -420,17 +345,11 @@ export declare class StatWatcher extends EventEmitter {
|
|
|
420
345
|
start(path: string, persistent?: boolean, interval?: number): void;
|
|
421
346
|
stop(): void;
|
|
422
347
|
}
|
|
423
|
-
export interface IReadStream extends Readable {
|
|
424
|
-
new (path: PathLike, options: IReadStreamOptions): any;
|
|
425
|
-
open(): any;
|
|
426
|
-
close(callback: TCallback<void>): any;
|
|
427
|
-
bytesRead: number;
|
|
428
|
-
path: string;
|
|
429
|
-
}
|
|
430
348
|
export interface IWriteStream extends Writable {
|
|
431
349
|
bytesWritten: number;
|
|
432
350
|
path: string;
|
|
433
|
-
|
|
351
|
+
pending: boolean;
|
|
352
|
+
new (path: PathLike, options: opts.IWriteStreamOptions): any;
|
|
434
353
|
open(): any;
|
|
435
354
|
close(): any;
|
|
436
355
|
}
|