@zenfs/core 1.0.10 → 1.0.11
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/backend.d.ts +4 -8
- package/dist/backends/backend.js +7 -11
- package/dist/backends/fetch.d.ts +2 -4
- package/dist/backends/fetch.js +1 -3
- package/dist/backends/memory.d.ts +1 -1
- package/dist/backends/overlay.d.ts +7 -3
- package/dist/backends/overlay.js +10 -6
- package/dist/backends/port/fs.d.ts +12 -17
- package/dist/backends/port/fs.js +5 -8
- package/dist/backends/port/rpc.d.ts +1 -1
- package/dist/backends/store/fs.d.ts +8 -10
- package/dist/backends/store/fs.js +30 -49
- package/dist/backends/store/simple.d.ts +1 -1
- package/dist/backends/store/simple.js +1 -1
- package/dist/backends/store/store.d.ts +7 -13
- package/dist/config.d.ts +5 -5
- package/dist/config.js +26 -26
- package/dist/emulation/async.d.ts +21 -176
- package/dist/emulation/async.js +17 -111
- package/dist/emulation/dir.d.ts +0 -1
- package/dist/emulation/path.d.ts +0 -4
- package/dist/emulation/path.js +4 -8
- package/dist/emulation/promises.d.ts +31 -121
- package/dist/emulation/promises.js +30 -97
- package/dist/emulation/shared.d.ts +7 -3
- package/dist/emulation/shared.js +8 -5
- package/dist/emulation/streams.d.ts +0 -3
- package/dist/emulation/sync.d.ts +25 -178
- package/dist/emulation/sync.js +36 -129
- package/dist/emulation/watchers.d.ts +0 -4
- package/dist/error.d.ts +11 -11
- package/dist/error.js +8 -10
- package/dist/file.d.ts +50 -171
- package/dist/file.js +33 -115
- package/dist/filesystem.d.ts +10 -62
- package/dist/filesystem.js +5 -6
- package/dist/mixins/async.d.ts +4 -6
- package/dist/mixins/async.js +3 -1
- package/dist/mixins/mutexed.d.ts +4 -4
- package/dist/mixins/mutexed.js +7 -5
- package/dist/mixins/readonly.js +14 -15
- package/dist/mixins/shared.d.ts +5 -5
- package/dist/mixins/sync.d.ts +2 -2
- package/dist/stats.d.ts +21 -37
- package/dist/stats.js +9 -21
- package/dist/utils.d.ts +1 -3
- package/package.json +4 -4
- package/src/backends/backend.ts +7 -11
- package/src/backends/fetch.ts +2 -4
- package/src/backends/memory.ts +1 -1
- package/src/backends/overlay.ts +8 -6
- package/src/backends/port/fs.ts +11 -14
- package/src/backends/port/rpc.ts +1 -0
- package/src/backends/store/fs.ts +30 -46
- package/src/backends/store/simple.ts +1 -1
- package/src/backends/store/store.ts +7 -13
- package/src/config.ts +26 -26
- package/src/emulation/async.ts +28 -178
- package/src/emulation/path.ts +4 -11
- package/src/emulation/promises.ts +34 -116
- package/src/emulation/shared.ts +8 -6
- package/src/emulation/sync.ts +41 -185
- package/src/error.ts +7 -11
- package/src/file.ts +47 -180
- package/src/filesystem.ts +14 -65
- package/src/mixins/async.ts +4 -6
- package/src/mixins/mutexed.ts +4 -4
- package/src/mixins/readonly.ts +15 -15
- package/src/mixins/shared.ts +5 -5
- package/src/mixins/sync.ts +3 -3
- package/src/stats.ts +21 -38
|
@@ -36,42 +36,36 @@ export declare abstract class Transaction<T extends Store = Store> {
|
|
|
36
36
|
*/
|
|
37
37
|
protected done: boolean;
|
|
38
38
|
/**
|
|
39
|
-
* Retrieves the data at
|
|
39
|
+
* Retrieves the data at `ino`.
|
|
40
40
|
* @param ino The key to look under for data.
|
|
41
41
|
*/
|
|
42
42
|
abstract get(ino: Ino): Promise<Uint8Array>;
|
|
43
43
|
/**
|
|
44
|
-
* Retrieves the data at
|
|
45
|
-
* or if the key does not exist.
|
|
44
|
+
* Retrieves the data at `ino`.
|
|
45
|
+
* Throws an error if an error occurs or if the key does not exist.
|
|
46
46
|
* @param ino The key to look under for data.
|
|
47
47
|
* @return The data stored under the key, or undefined if not present.
|
|
48
48
|
*/
|
|
49
49
|
abstract getSync(ino: Ino): Uint8Array;
|
|
50
50
|
/**
|
|
51
|
-
* Adds the data to the store under
|
|
52
|
-
* data.
|
|
51
|
+
* Adds the data to the store under `ino`. Overwrites any existing data.
|
|
53
52
|
* @param ino The key to add the data under.
|
|
54
53
|
* @param data The data to add to the store.
|
|
55
|
-
* @param overwrite If 'true', overwrite any existing data. If 'false',
|
|
56
|
-
* avoids writing the data if the key exists.
|
|
57
54
|
*/
|
|
58
55
|
abstract set(ino: Ino, data: Uint8Array): Promise<void>;
|
|
59
56
|
/**
|
|
60
|
-
* Adds the data to the store under
|
|
57
|
+
* Adds the data to the store under `ino`.
|
|
61
58
|
* @param ino The key to add the data under.
|
|
62
59
|
* @param data The data to add to the store.
|
|
63
|
-
* @param overwrite If 'true', overwrite any existing data. If 'false',
|
|
64
|
-
* avoids storing the data if the key exists.
|
|
65
|
-
* @return True if storage succeeded, false otherwise.
|
|
66
60
|
*/
|
|
67
61
|
abstract setSync(ino: Ino, data: Uint8Array): void;
|
|
68
62
|
/**
|
|
69
|
-
* Deletes the data at
|
|
63
|
+
* Deletes the data at `ino`.
|
|
70
64
|
* @param ino The key to delete from the store.
|
|
71
65
|
*/
|
|
72
66
|
abstract remove(ino: Ino): Promise<void>;
|
|
73
67
|
/**
|
|
74
|
-
* Deletes the data at
|
|
68
|
+
* Deletes the data at `ino`.
|
|
75
69
|
* @param ino The key to delete from the store.
|
|
76
70
|
*/
|
|
77
71
|
abstract removeSync(ino: Ino): void;
|
package/dist/config.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ import type { AbsolutePath } from './emulation/path.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export type MountConfiguration<T extends Backend> = FilesystemOf<T> | BackendConfiguration<T> | T;
|
|
7
7
|
/**
|
|
8
|
-
* Retrieve a file system with
|
|
8
|
+
* Retrieve a file system with `configuration`.
|
|
9
9
|
* @see MountConfiguration
|
|
10
10
|
*/
|
|
11
|
-
export declare function resolveMountConfig<T extends Backend>(
|
|
11
|
+
export declare function resolveMountConfig<T extends Backend>(configuration: MountConfiguration<T>, _depth?: number): Promise<FilesystemOf<T>>;
|
|
12
12
|
export interface ConfigMounts {
|
|
13
13
|
[K: AbsolutePath]: Backend;
|
|
14
14
|
}
|
|
@@ -34,9 +34,9 @@ export interface Configuration<T extends ConfigMounts> extends SharedConfig {
|
|
|
34
34
|
/**
|
|
35
35
|
* Configures ZenFS with single mount point /
|
|
36
36
|
*/
|
|
37
|
-
export declare function configureSingle<T extends Backend>(
|
|
37
|
+
export declare function configureSingle<T extends Backend>(configuration: MountConfiguration<T>): Promise<void>;
|
|
38
38
|
/**
|
|
39
|
-
* Configures ZenFS with
|
|
39
|
+
* Configures ZenFS with `configuration`
|
|
40
40
|
* @see Configuration
|
|
41
41
|
*/
|
|
42
|
-
export declare function configure<T extends ConfigMounts>(
|
|
42
|
+
export declare function configure<T extends ConfigMounts>(configuration: Partial<Configuration<T>>): Promise<void>;
|
package/dist/config.js
CHANGED
|
@@ -7,23 +7,23 @@ function isMountConfig(arg) {
|
|
|
7
7
|
return isBackendConfig(arg) || isBackend(arg) || arg instanceof FileSystem;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Retrieve a file system with
|
|
10
|
+
* Retrieve a file system with `configuration`.
|
|
11
11
|
* @see MountConfiguration
|
|
12
12
|
*/
|
|
13
|
-
export async function resolveMountConfig(
|
|
14
|
-
if (typeof
|
|
13
|
+
export async function resolveMountConfig(configuration, _depth = 0) {
|
|
14
|
+
if (typeof configuration !== 'object' || configuration == null) {
|
|
15
15
|
throw new ErrnoError(Errno.EINVAL, 'Invalid options on mount configuration');
|
|
16
16
|
}
|
|
17
|
-
if (!isMountConfig(
|
|
17
|
+
if (!isMountConfig(configuration)) {
|
|
18
18
|
throw new ErrnoError(Errno.EINVAL, 'Invalid mount configuration');
|
|
19
19
|
}
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
20
|
+
if (configuration instanceof FileSystem) {
|
|
21
|
+
return configuration;
|
|
22
22
|
}
|
|
23
|
-
if (isBackend(
|
|
24
|
-
|
|
23
|
+
if (isBackend(configuration)) {
|
|
24
|
+
configuration = { backend: configuration };
|
|
25
25
|
}
|
|
26
|
-
for (const [key, value] of Object.entries(
|
|
26
|
+
for (const [key, value] of Object.entries(configuration)) {
|
|
27
27
|
if (key == 'backend') {
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
@@ -33,48 +33,48 @@ export async function resolveMountConfig(config, _depth = 0) {
|
|
|
33
33
|
if (_depth > 10) {
|
|
34
34
|
throw new ErrnoError(Errno.EINVAL, 'Invalid configuration, too deep and possibly infinite');
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
configuration[key] = await resolveMountConfig(value, ++_depth);
|
|
37
37
|
}
|
|
38
|
-
const { backend } =
|
|
38
|
+
const { backend } = configuration;
|
|
39
39
|
if (!(await backend.isAvailable())) {
|
|
40
40
|
throw new ErrnoError(Errno.EPERM, 'Backend not available: ' + backend.name);
|
|
41
41
|
}
|
|
42
|
-
await checkOptions(backend,
|
|
43
|
-
const mount = (await backend.create(
|
|
44
|
-
mount._disableSync =
|
|
42
|
+
await checkOptions(backend, configuration);
|
|
43
|
+
const mount = (await backend.create(configuration));
|
|
44
|
+
mount._disableSync = configuration.disableAsyncCache || false;
|
|
45
45
|
await mount.ready();
|
|
46
46
|
return mount;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Configures ZenFS with single mount point /
|
|
50
50
|
*/
|
|
51
|
-
export async function configureSingle(
|
|
52
|
-
if (!isBackendConfig(
|
|
51
|
+
export async function configureSingle(configuration) {
|
|
52
|
+
if (!isBackendConfig(configuration)) {
|
|
53
53
|
throw new TypeError('Invalid single mount point configuration');
|
|
54
54
|
}
|
|
55
|
-
const resolved = await resolveMountConfig(
|
|
55
|
+
const resolved = await resolveMountConfig(configuration);
|
|
56
56
|
fs.umount('/');
|
|
57
57
|
fs.mount('/', resolved);
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
* Configures ZenFS with
|
|
60
|
+
* Configures ZenFS with `configuration`
|
|
61
61
|
* @see Configuration
|
|
62
62
|
*/
|
|
63
|
-
export async function configure(
|
|
64
|
-
const uid = 'uid' in
|
|
65
|
-
const gid = 'gid' in
|
|
63
|
+
export async function configure(configuration) {
|
|
64
|
+
const uid = 'uid' in configuration ? configuration.uid || 0 : 0;
|
|
65
|
+
const gid = 'gid' in configuration ? configuration.gid || 0 : 0;
|
|
66
66
|
Object.assign(credentials, { uid, gid, suid: uid, sgid: gid, euid: uid, egid: gid });
|
|
67
|
-
if (!
|
|
67
|
+
if (!configuration.mounts) {
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
for (const [point, mountConfig] of Object.entries(
|
|
70
|
+
for (const [point, mountConfig] of Object.entries(configuration.mounts)) {
|
|
71
71
|
if (!point.startsWith('/')) {
|
|
72
72
|
throw new ErrnoError(Errno.EINVAL, 'Mount points must have absolute paths');
|
|
73
73
|
}
|
|
74
74
|
if (isBackendConfig(mountConfig)) {
|
|
75
|
-
mountConfig.disableAsyncCache ?? (mountConfig.disableAsyncCache =
|
|
75
|
+
mountConfig.disableAsyncCache ?? (mountConfig.disableAsyncCache = configuration.disableAsyncCache || false);
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
configuration.mounts[point] = await resolveMountConfig(mountConfig);
|
|
78
78
|
}
|
|
79
|
-
fs.mountObject(
|
|
79
|
+
fs.mountObject(configuration.mounts);
|
|
80
80
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
4
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
5
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
6
1
|
import { Buffer } from 'buffer';
|
|
7
2
|
import type * as fs from 'node:fs';
|
|
8
3
|
import type { FileContents } from '../filesystem.js';
|
|
@@ -14,26 +9,15 @@ import * as promises from './promises.js';
|
|
|
14
9
|
import { ReadStream, WriteStream } from './streams.js';
|
|
15
10
|
import { FSWatcher } from './watchers.js';
|
|
16
11
|
/**
|
|
17
|
-
* Asynchronous rename. No arguments other than a possible exception are given
|
|
18
|
-
* to the completion callback.
|
|
19
|
-
* @param oldPath
|
|
20
|
-
* @param newPath
|
|
21
|
-
* @param callback
|
|
12
|
+
* Asynchronous rename. No arguments other than a possible exception are given to the completion callback.
|
|
22
13
|
*/
|
|
23
14
|
export declare function rename(oldPath: fs.PathLike, newPath: fs.PathLike, cb?: Callback): void;
|
|
24
15
|
/**
|
|
25
|
-
* Test whether or not
|
|
16
|
+
* Test whether or not `path` exists by checking with the file system.
|
|
26
17
|
* Then call the callback argument with either true or false.
|
|
27
|
-
* @param path
|
|
28
|
-
* @param callback
|
|
29
18
|
* @deprecated Use {@link stat} or {@link access} instead.
|
|
30
19
|
*/
|
|
31
20
|
export declare function exists(path: fs.PathLike, cb?: (exists: boolean) => unknown): void;
|
|
32
|
-
/**
|
|
33
|
-
* Asynchronous `stat`.
|
|
34
|
-
* @param path
|
|
35
|
-
* @param callback
|
|
36
|
-
*/
|
|
37
21
|
export declare function stat(path: fs.PathLike, callback: Callback<[Stats]>): void;
|
|
38
22
|
export declare function stat(path: fs.PathLike, options: {
|
|
39
23
|
bigint?: false;
|
|
@@ -46,8 +30,6 @@ export declare function stat(path: fs.PathLike, options: fs.StatOptions, callbac
|
|
|
46
30
|
* Asynchronous `lstat`.
|
|
47
31
|
* `lstat()` is identical to `stat()`, except that if path is a symbolic link,
|
|
48
32
|
* then the link itself is stat-ed, not the file that it refers to.
|
|
49
|
-
* @param path
|
|
50
|
-
* @param callback
|
|
51
33
|
*/
|
|
52
34
|
export declare function lstat(path: fs.PathLike, callback: Callback<[Stats]>): void;
|
|
53
35
|
export declare function lstat(path: fs.PathLike, options: fs.StatOptions & {
|
|
@@ -57,23 +39,13 @@ export declare function lstat(path: fs.PathLike, options: fs.StatOptions & {
|
|
|
57
39
|
bigint: true;
|
|
58
40
|
}, callback: Callback<[BigIntStats]>): void;
|
|
59
41
|
export declare function lstat(path: fs.PathLike, options: fs.StatOptions, callback: Callback<[Stats | BigIntStats]>): void;
|
|
60
|
-
/**
|
|
61
|
-
* Asynchronous `truncate`.
|
|
62
|
-
* @param path
|
|
63
|
-
* @param len
|
|
64
|
-
* @param callback
|
|
65
|
-
*/
|
|
66
42
|
export declare function truncate(path: fs.PathLike, cb?: Callback): void;
|
|
67
43
|
export declare function truncate(path: fs.PathLike, len: number, cb?: Callback): void;
|
|
68
|
-
/**
|
|
69
|
-
* Asynchronous `unlink`.
|
|
70
|
-
* @param path
|
|
71
|
-
* @param callback
|
|
72
|
-
*/
|
|
73
44
|
export declare function unlink(path: fs.PathLike, cb?: Callback): void;
|
|
74
45
|
/**
|
|
75
46
|
* Asynchronous file open.
|
|
76
47
|
* Exclusive mode ensures that path is newly created.
|
|
48
|
+
* Mode defaults to `0644`
|
|
77
49
|
*
|
|
78
50
|
* `flags` can be:
|
|
79
51
|
*
|
|
@@ -91,20 +63,14 @@ export declare function unlink(path: fs.PathLike, cb?: Callback): void;
|
|
|
91
63
|
* * `'ax+'` - Like 'a+' but opens the file in exclusive mode.
|
|
92
64
|
*
|
|
93
65
|
* @see http://www.manpagez.com/man/2/open/
|
|
94
|
-
* @param path
|
|
95
|
-
* @param flags
|
|
96
|
-
* @param mode defaults to `0644`
|
|
97
|
-
* @param callback
|
|
98
66
|
*/
|
|
99
67
|
export declare function open(path: fs.PathLike, flag: string, cb?: Callback<[number]>): void;
|
|
100
68
|
export declare function open(path: fs.PathLike, flag: string, mode: number | string, cb?: Callback<[number]>): void;
|
|
101
69
|
/**
|
|
102
70
|
* Asynchronously reads the entire contents of a file.
|
|
103
|
-
* @
|
|
104
|
-
* @
|
|
105
|
-
* @
|
|
106
|
-
* @option options flag Defaults to `'r'`.
|
|
107
|
-
* @param callback If no encoding is specified, then the raw buffer is returned.
|
|
71
|
+
* @option encoding The string encoding for the file contents. Defaults to `null`.
|
|
72
|
+
* @option flag Defaults to `'r'`.
|
|
73
|
+
* @param cb If no encoding is specified, then the raw buffer is returned.
|
|
108
74
|
*/
|
|
109
75
|
export declare function readFile(filename: fs.PathLike, cb: Callback<[Uint8Array]>): void;
|
|
110
76
|
export declare function readFile(filename: fs.PathLike, options: {
|
|
@@ -120,13 +86,9 @@ export declare function readFile(filename: fs.PathLike, options: {
|
|
|
120
86
|
*
|
|
121
87
|
* The encoding option is ignored if data is a buffer.
|
|
122
88
|
*
|
|
123
|
-
* @param filename
|
|
124
|
-
* @param data
|
|
125
|
-
* @param options
|
|
126
89
|
* @option encoding Defaults to `'utf8'`.
|
|
127
90
|
* @option mode Defaults to `0644`.
|
|
128
91
|
* @option flag Defaults to `'w'`.
|
|
129
|
-
* @param callback
|
|
130
92
|
*/
|
|
131
93
|
export declare function writeFile(filename: fs.PathLike, data: FileContents, cb?: Callback): void;
|
|
132
94
|
export declare function writeFile(filename: fs.PathLike, data: FileContents, encoding?: BufferEncoding, cb?: Callback): void;
|
|
@@ -135,13 +97,9 @@ export declare function writeFile(filename: fs.PathLike, data: FileContents, opt
|
|
|
135
97
|
* Asynchronously append data to a file, creating the file if it not yet
|
|
136
98
|
* exists.
|
|
137
99
|
*
|
|
138
|
-
* @param filename
|
|
139
|
-
* @param data
|
|
140
|
-
* @param options
|
|
141
100
|
* @option encoding Defaults to `'utf8'`.
|
|
142
101
|
* @option mode Defaults to `0644`.
|
|
143
102
|
* @option flag Defaults to `'a'`.
|
|
144
|
-
* @param callback
|
|
145
103
|
*/
|
|
146
104
|
export declare function appendFile(filename: fs.PathLike, data: FileContents, cb?: Callback): void;
|
|
147
105
|
export declare function appendFile(filename: fs.PathLike, data: FileContents, options?: fs.EncodingOption & {
|
|
@@ -151,10 +109,7 @@ export declare function appendFile(filename: fs.PathLike, data: FileContents, op
|
|
|
151
109
|
export declare function appendFile(filename: fs.PathLike, data: FileContents, encoding?: BufferEncoding, cb?: Callback): void;
|
|
152
110
|
/**
|
|
153
111
|
* Asynchronous `fstat`.
|
|
154
|
-
* `fstat()` is identical to `stat()`, except that the file to be stat-ed is
|
|
155
|
-
* specified by the file descriptor `fd`.
|
|
156
|
-
* @param fd
|
|
157
|
-
* @param callback
|
|
112
|
+
* `fstat()` is identical to `stat()`, except that the file to be stat-ed is specified by the file descriptor `fd`.
|
|
158
113
|
*/
|
|
159
114
|
export declare function fstat(fd: number, cb: Callback<[Stats]>): void;
|
|
160
115
|
export declare function fstat(fd: number, options: fs.StatOptions & {
|
|
@@ -163,45 +118,20 @@ export declare function fstat(fd: number, options: fs.StatOptions & {
|
|
|
163
118
|
export declare function fstat(fd: number, options: fs.StatOptions & {
|
|
164
119
|
bigint: true;
|
|
165
120
|
}, cb: Callback<[BigIntStats]>): void;
|
|
166
|
-
/**
|
|
167
|
-
* Asynchronous close.
|
|
168
|
-
* @param fd
|
|
169
|
-
* @param callback
|
|
170
|
-
*/
|
|
171
121
|
export declare function close(fd: number, cb?: Callback): void;
|
|
172
|
-
/**
|
|
173
|
-
* Asynchronous ftruncate.
|
|
174
|
-
* @param fd
|
|
175
|
-
* @param len
|
|
176
|
-
* @param callback
|
|
177
|
-
*/
|
|
178
122
|
export declare function ftruncate(fd: number, cb?: Callback): void;
|
|
179
123
|
export declare function ftruncate(fd: number, len?: number, cb?: Callback): void;
|
|
180
|
-
/**
|
|
181
|
-
* Asynchronous fsync.
|
|
182
|
-
* @param fd
|
|
183
|
-
* @param callback
|
|
184
|
-
*/
|
|
185
124
|
export declare function fsync(fd: number, cb?: Callback): void;
|
|
186
|
-
/**
|
|
187
|
-
* Asynchronous fdatasync.
|
|
188
|
-
* @param fd
|
|
189
|
-
* @param callback
|
|
190
|
-
*/
|
|
191
125
|
export declare function fdatasync(fd: number, cb?: Callback): void;
|
|
192
126
|
/**
|
|
193
127
|
* Write buffer to the file specified by `fd`.
|
|
194
|
-
* Note that it is unsafe to use fs.write multiple times on the same file
|
|
195
|
-
*
|
|
196
|
-
* @param fd
|
|
197
|
-
* @param buffer Uint8Array containing the data to write to
|
|
198
|
-
* the file.
|
|
128
|
+
* Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback.
|
|
129
|
+
* @param buffer Uint8Array containing the data to write to the file.
|
|
199
130
|
* @param offset Offset in the buffer to start reading data from.
|
|
200
131
|
* @param length The amount of bytes to write to the file.
|
|
201
|
-
* @param position Offset from the beginning of the file where this
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
* @param callback The number specifies the number of bytes written into the file.
|
|
132
|
+
* @param position Offset from the beginning of the file where this data should be written.
|
|
133
|
+
* If position is null, the data will be written at the current position.
|
|
134
|
+
* @param cb The number specifies the number of bytes written into the file.
|
|
205
135
|
*/
|
|
206
136
|
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, cb?: Callback<[number, Uint8Array]>): void;
|
|
207
137
|
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: Callback<[number, Uint8Array]>): void;
|
|
@@ -210,60 +140,30 @@ export declare function write(fd: number, data: FileContents, position?: number,
|
|
|
210
140
|
export declare function write(fd: number, data: FileContents, position: number | null, encoding: BufferEncoding, cb?: Callback<[number, string]>): void;
|
|
211
141
|
/**
|
|
212
142
|
* Read data from the file specified by `fd`.
|
|
213
|
-
* @param buffer The buffer that the data will be
|
|
214
|
-
*
|
|
215
|
-
* @param offset The offset within the buffer where writing will
|
|
216
|
-
* start.
|
|
143
|
+
* @param buffer The buffer that the data will be written to.
|
|
144
|
+
* @param offset The offset within the buffer where writing will start.
|
|
217
145
|
* @param length An integer specifying the number of bytes to read.
|
|
218
|
-
* @param position An integer specifying where to begin reading from
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
* @param callback The number is the number of bytes read
|
|
146
|
+
* @param position An integer specifying where to begin reading from in the file.
|
|
147
|
+
* If position is null, data will be read from the current file position.
|
|
148
|
+
* @param cb The number is the number of bytes read
|
|
222
149
|
*/
|
|
223
150
|
export declare function read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: Callback<[number, Uint8Array]>): void;
|
|
224
|
-
/**
|
|
225
|
-
* Asynchronous `fchown`.
|
|
226
|
-
* @param fd
|
|
227
|
-
* @param uid
|
|
228
|
-
* @param gid
|
|
229
|
-
* @param callback
|
|
230
|
-
*/
|
|
231
151
|
export declare function fchown(fd: number, uid: number, gid: number, cb?: Callback): void;
|
|
232
|
-
/**
|
|
233
|
-
* Asynchronous `fchmod`.
|
|
234
|
-
* @param fd
|
|
235
|
-
* @param mode
|
|
236
|
-
* @param callback
|
|
237
|
-
*/
|
|
238
152
|
export declare function fchmod(fd: number, mode: string | number, cb: Callback): void;
|
|
239
153
|
/**
|
|
240
|
-
* Change the file timestamps of a file referenced by the supplied file
|
|
241
|
-
* descriptor.
|
|
242
|
-
* @param fd
|
|
243
|
-
* @param atime
|
|
244
|
-
* @param mtime
|
|
245
|
-
* @param callback
|
|
154
|
+
* Change the file timestamps of a file referenced by the supplied file descriptor.
|
|
246
155
|
*/
|
|
247
156
|
export declare function futimes(fd: number, atime: number | Date, mtime: number | Date, cb?: Callback): void;
|
|
248
|
-
/**
|
|
249
|
-
* Asynchronous `rmdir`.
|
|
250
|
-
* @param path
|
|
251
|
-
* @param callback
|
|
252
|
-
*/
|
|
253
157
|
export declare function rmdir(path: fs.PathLike, cb?: Callback): void;
|
|
254
158
|
/**
|
|
255
159
|
* Asynchronous `mkdir`.
|
|
256
|
-
* @param path
|
|
257
160
|
* @param mode defaults to `0777`
|
|
258
|
-
* @param callback
|
|
259
161
|
*/
|
|
260
162
|
export declare function mkdir(path: fs.PathLike, mode?: fs.Mode, cb?: Callback): void;
|
|
261
163
|
/**
|
|
262
164
|
* Asynchronous `readdir`. Reads the contents of a directory.
|
|
263
165
|
* The callback gets two arguments `(err, files)` where `files` is an array of
|
|
264
166
|
* the names of the files in the directory excluding `'.'` and `'..'`.
|
|
265
|
-
* @param path
|
|
266
|
-
* @param callback
|
|
267
167
|
*/
|
|
268
168
|
export declare function readdir(path: fs.PathLike, cb: Callback<[string[]]>): void;
|
|
269
169
|
export declare function readdir(path: fs.PathLike, options: {
|
|
@@ -272,92 +172,37 @@ export declare function readdir(path: fs.PathLike, options: {
|
|
|
272
172
|
export declare function readdir(path: fs.PathLike, options: {
|
|
273
173
|
withFileTypes: true;
|
|
274
174
|
}, cb: Callback<[Dirent[]]>): void;
|
|
275
|
-
/**
|
|
276
|
-
* Asynchronous `link`.
|
|
277
|
-
* @param existing
|
|
278
|
-
* @param newpath
|
|
279
|
-
* @param callback
|
|
280
|
-
*/
|
|
281
175
|
export declare function link(existing: fs.PathLike, newpath: fs.PathLike, cb?: Callback): void;
|
|
282
176
|
/**
|
|
283
177
|
* Asynchronous `symlink`.
|
|
284
178
|
* @param target target path
|
|
285
179
|
* @param path link path
|
|
286
|
-
*
|
|
287
|
-
* @param callback
|
|
180
|
+
* Type defaults to file
|
|
288
181
|
*/
|
|
289
182
|
export declare function symlink(target: fs.PathLike, path: fs.PathLike, cb?: Callback): void;
|
|
290
183
|
export declare function symlink(target: fs.PathLike, path: fs.PathLike, type?: fs.symlink.Type, cb?: Callback): void;
|
|
291
|
-
/**
|
|
292
|
-
* Asynchronous readlink.
|
|
293
|
-
* @param path
|
|
294
|
-
* @param callback
|
|
295
|
-
*/
|
|
296
184
|
export declare function readlink(path: fs.PathLike, callback: Callback<[string]> & any): void;
|
|
297
185
|
export declare function readlink(path: fs.PathLike, options: fs.BufferEncodingOption, callback: Callback<[Uint8Array]>): void;
|
|
298
186
|
export declare function readlink(path: fs.PathLike, options: fs.EncodingOption, callback: Callback<[string | Uint8Array]>): void;
|
|
299
187
|
export declare function readlink(path: fs.PathLike, options: fs.EncodingOption, callback: Callback<[string]>): void;
|
|
300
|
-
/**
|
|
301
|
-
* Asynchronous `chown`.
|
|
302
|
-
* @param path
|
|
303
|
-
* @param uid
|
|
304
|
-
* @param gid
|
|
305
|
-
* @param callback
|
|
306
|
-
*/
|
|
307
188
|
export declare function chown(path: fs.PathLike, uid: number, gid: number, cb?: Callback): void;
|
|
308
|
-
/**
|
|
309
|
-
* Asynchronous `lchown`.
|
|
310
|
-
* @param path
|
|
311
|
-
* @param uid
|
|
312
|
-
* @param gid
|
|
313
|
-
* @param callback
|
|
314
|
-
*/
|
|
315
189
|
export declare function lchown(path: fs.PathLike, uid: number, gid: number, cb?: Callback): void;
|
|
316
|
-
/**
|
|
317
|
-
* Asynchronous `chmod`.
|
|
318
|
-
* @param path
|
|
319
|
-
* @param mode
|
|
320
|
-
* @param callback
|
|
321
|
-
*/
|
|
322
190
|
export declare function chmod(path: fs.PathLike, mode: number | string, cb?: Callback): void;
|
|
323
|
-
/**
|
|
324
|
-
* Asynchronous `lchmod`.
|
|
325
|
-
* @param path
|
|
326
|
-
* @param mode
|
|
327
|
-
* @param callback
|
|
328
|
-
*/
|
|
329
191
|
export declare function lchmod(path: fs.PathLike, mode: number | string, cb?: Callback): void;
|
|
330
192
|
/**
|
|
331
193
|
* Change file timestamps of the file referenced by the supplied path.
|
|
332
|
-
* @param path
|
|
333
|
-
* @param atime
|
|
334
|
-
* @param mtime
|
|
335
|
-
* @param callback
|
|
336
194
|
*/
|
|
337
195
|
export declare function utimes(path: fs.PathLike, atime: number | Date, mtime: number | Date, cb?: Callback): void;
|
|
338
196
|
/**
|
|
339
197
|
* Change file timestamps of the file referenced by the supplied path.
|
|
340
|
-
* @param path
|
|
341
|
-
* @param atime
|
|
342
|
-
* @param mtime
|
|
343
|
-
* @param callback
|
|
344
198
|
*/
|
|
345
199
|
export declare function lutimes(path: fs.PathLike, atime: number | Date, mtime: number | Date, cb?: Callback): void;
|
|
346
200
|
/**
|
|
347
201
|
* Asynchronous `realpath`. The callback gets two arguments
|
|
348
202
|
* `(err, resolvedPath)`. May use `process.cwd` to resolve relative paths.
|
|
349
|
-
*
|
|
350
|
-
* @param path
|
|
351
|
-
* @param callback
|
|
352
203
|
*/
|
|
353
204
|
export declare function realpath(path: fs.PathLike, cb?: Callback<[string]>): void;
|
|
354
205
|
export declare function realpath(path: fs.PathLike, options: fs.EncodingOption, cb: Callback<[string]>): void;
|
|
355
|
-
/**
|
|
356
|
-
* Asynchronous `access`.
|
|
357
|
-
* @param path
|
|
358
|
-
* @param mode
|
|
359
|
-
* @param callback
|
|
360
|
-
*/
|
|
361
206
|
export declare function access(path: fs.PathLike, cb: Callback): void;
|
|
362
207
|
export declare function access(path: fs.PathLike, mode: number, cb: Callback): void;
|
|
363
208
|
/**
|
|
@@ -425,7 +270,7 @@ interface WriteStreamOptions extends StreamOptions {
|
|
|
425
270
|
* @param options Options for the ReadStream and file opening (e.g., `encoding`, `highWaterMark`, `mode`).
|
|
426
271
|
* @returns A ReadStream object for interacting with the file's contents.
|
|
427
272
|
*/
|
|
428
|
-
export declare function createReadStream(path: fs.PathLike,
|
|
273
|
+
export declare function createReadStream(path: fs.PathLike, options?: BufferEncoding | ReadStreamOptions): ReadStream;
|
|
429
274
|
/**
|
|
430
275
|
* Opens a file in write mode and creates a Node.js-like WriteStream.
|
|
431
276
|
*
|
|
@@ -433,7 +278,7 @@ export declare function createReadStream(path: fs.PathLike, _options?: BufferEnc
|
|
|
433
278
|
* @param options Options for the WriteStream and file opening (e.g., `encoding`, `highWaterMark`, `mode`).
|
|
434
279
|
* @returns A WriteStream object for writing to the file.
|
|
435
280
|
*/
|
|
436
|
-
export declare function createWriteStream(path: fs.PathLike,
|
|
281
|
+
export declare function createWriteStream(path: fs.PathLike, options?: BufferEncoding | WriteStreamOptions): WriteStream;
|
|
437
282
|
export declare function rm(path: fs.PathLike, callback: Callback): void;
|
|
438
283
|
export declare function rm(path: fs.PathLike, options: fs.RmOptions, callback: Callback): void;
|
|
439
284
|
/**
|