bare-fs 4.8.0 → 4.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -957
- package/index.d.ts +268 -0
- package/index.js +19 -7
- package/lib/constants.d.ts +1 -0
- package/lib/errors.d.ts +2 -0
- package/package.json +1 -1
- package/prebuilds/android-arm/bare-fs.bare +0 -0
- package/prebuilds/android-arm64/bare-fs.bare +0 -0
- package/prebuilds/android-ia32/bare-fs.bare +0 -0
- package/prebuilds/android-x64/bare-fs.bare +0 -0
- package/prebuilds/darwin-arm64/bare-fs.bare +0 -0
- package/prebuilds/darwin-x64/bare-fs.bare +0 -0
- package/prebuilds/ios-arm64/bare-fs.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-fs.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-fs.bare +0 -0
- package/prebuilds/linux-arm64/bare-fs.bare +0 -0
- package/prebuilds/linux-x64/bare-fs.bare +0 -0
- package/prebuilds/win32-arm64/bare-fs.bare +0 -0
- package/prebuilds/win32-x64/bare-fs.bare +0 -0
- package/promises.d.ts +167 -0
package/lib/constants.d.ts
CHANGED
package/lib/errors.d.ts
CHANGED
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/promises.d.ts
CHANGED
|
@@ -29,14 +29,28 @@ import {
|
|
|
29
29
|
export { constants }
|
|
30
30
|
|
|
31
31
|
interface FileHandleEvents extends EventMap {
|
|
32
|
+
/** Emitted once the file handle has closed. */
|
|
32
33
|
close: []
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
interface FileHandle extends EventEmitter<FileHandleEvents>, AsyncDisposable {
|
|
37
|
+
/** The underlying file descriptor. */
|
|
36
38
|
readonly fd: number
|
|
37
39
|
|
|
40
|
+
/** Close the underlying file descriptor. */
|
|
38
41
|
close(): Promise<void>
|
|
39
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Read from a file descriptor into `buffer`. `offset` defaults to `0`, `len` defaults to
|
|
45
|
+
* `buffer.byteLength - offset`, and `pos` defaults to `-1` (current position). Returns the number
|
|
46
|
+
* of bytes read.
|
|
47
|
+
* @param fd - The file descriptor to read from, as returned by `fs.open()`.
|
|
48
|
+
* @param offset - The offset within `buffer` to start writing to. Defaults to `0`.
|
|
49
|
+
* @param len - The number of bytes to read. Defaults to `buffer.byteLength - offset`.
|
|
50
|
+
* @param pos - The position in the file to read from. Defaults to `-1`, which reads from the
|
|
51
|
+
* current file position and advances it.
|
|
52
|
+
* @returns The number of bytes actually read, which may be less than `len` (`0` at end of file).
|
|
53
|
+
*/
|
|
40
54
|
read(
|
|
41
55
|
buffer: Buffer | ArrayBufferView,
|
|
42
56
|
offset?: number,
|
|
@@ -44,8 +58,25 @@ interface FileHandle extends EventEmitter<FileHandleEvents>, AsyncDisposable {
|
|
|
44
58
|
pos?: number
|
|
45
59
|
): Promise<number>
|
|
46
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Read from a file descriptor into an array of `buffers`. `pos` defaults to `-1`.
|
|
63
|
+
* @returns The number of bytes actually read across all buffers.
|
|
64
|
+
*/
|
|
47
65
|
readv(buffers: ArrayBufferView[], position?: number): Promise<number>
|
|
48
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Write `data` to a file descriptor. When `data` is a string, the signature is
|
|
69
|
+
* `fs.write(fd, data[, pos[, encoding]])` where `encoding` defaults to `'utf8'`. Returns the
|
|
70
|
+
* number of bytes written.
|
|
71
|
+
* @param fd - The file descriptor to write to, as returned by `fs.open()`.
|
|
72
|
+
* @param data - The bytes to write. May also be a string, in which case the signature becomes
|
|
73
|
+
* `fs.write(fd, data[, pos[, encoding]])`.
|
|
74
|
+
* @param offset - The offset within `data` to start writing from. Defaults to `0`.
|
|
75
|
+
* @param len - The number of bytes to write. Defaults to `data.byteLength - offset`.
|
|
76
|
+
* @param pos - The position in the file to write to. Defaults to `-1`, which writes at the
|
|
77
|
+
* current file position and advances it.
|
|
78
|
+
* @returns The number of bytes actually written, which may be less than `data`'s length.
|
|
79
|
+
*/
|
|
49
80
|
write(
|
|
50
81
|
data: Buffer | ArrayBufferView,
|
|
51
82
|
offset?: number,
|
|
@@ -55,22 +86,46 @@ interface FileHandle extends EventEmitter<FileHandleEvents>, AsyncDisposable {
|
|
|
55
86
|
|
|
56
87
|
write(data: string, pos?: number, encoding?: BufferEncoding): Promise<number>
|
|
57
88
|
|
|
89
|
+
/** Get the status of a file. Returns a `Stats` object. */
|
|
58
90
|
stat(): Promise<Stats>
|
|
59
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Change the permissions of a file. `mode` may be a numeric mode or a string that will be parsed
|
|
94
|
+
* as octal.
|
|
95
|
+
*/
|
|
60
96
|
chmod(mode: string | number): Promise<void>
|
|
61
97
|
|
|
98
|
+
/** Change the owner and group of a file. */
|
|
62
99
|
chown(uid: number, gid: number): Promise<void>
|
|
63
100
|
|
|
64
101
|
datasync(): Promise<void>
|
|
65
102
|
|
|
66
103
|
sync(): Promise<void>
|
|
67
104
|
|
|
105
|
+
/** Truncate the file at `filename` to `len` bytes. `len` defaults to `0`. */
|
|
68
106
|
truncate(len?: number): Promise<void>
|
|
69
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Change the access and modification times of a file. Times may be numbers (seconds since epoch)
|
|
110
|
+
* or `Date` objects.
|
|
111
|
+
*/
|
|
70
112
|
utimes(atime: number | Date, mtime: number | Date): Promise<void>
|
|
71
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Create a readable stream for a file. Returns a `ReadStream`.
|
|
116
|
+
* @param path - May be `null` if `opts.fd` specifies an already-open file descriptor to read from
|
|
117
|
+
* instead of opening `path`.
|
|
118
|
+
* @param opts - `flags` defaults to `'r'`, `mode` to `0o666`, `start` (byte offset) to `0`; `end`
|
|
119
|
+
* (inclusive byte offset), if given, stops the stream early.
|
|
120
|
+
*/
|
|
72
121
|
createReadStream(opts?: ReadStreamOptions): ReadStream
|
|
73
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Create a writable stream for a file. Returns a `WriteStream`.
|
|
125
|
+
* @param path - May be `null` if `opts.fd` specifies an already-open file descriptor to write to
|
|
126
|
+
* instead of opening `path`.
|
|
127
|
+
* @param opts - `flags` defaults to `'w'`, `mode` to `0o666`.
|
|
128
|
+
*/
|
|
74
129
|
createWriteStream(opts?: WriteStreamOptions): WriteStream
|
|
75
130
|
}
|
|
76
131
|
|
|
@@ -78,14 +133,36 @@ declare class FileHandle {
|
|
|
78
133
|
private constructor(fd: number)
|
|
79
134
|
}
|
|
80
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Open a file, returning a file descriptor. `flags` defaults to `'r'` and `mode` defaults to
|
|
138
|
+
* `0o666`. `flags` may be a string such as `'r'`, `'w'`, `'a'`, `'r+'`, etc., or a numeric
|
|
139
|
+
* combination of `fs.constants` flags.
|
|
140
|
+
* @param flags - Defaults to `'r'`. Selects read/write mode and whether the file is created,
|
|
141
|
+
* truncated, or appended.
|
|
142
|
+
* @param mode - Defaults to `0o666`. Applied only when `flags` creates a new file.
|
|
143
|
+
* @returns The file descriptor for the newly opened file.
|
|
144
|
+
* @throws {ENOENT} `filepath` does not exist and `flags` does not include a creating variant (for
|
|
145
|
+
* example the default `'r'`).
|
|
146
|
+
* @throws {EEXIST} `flags` is an exclusive variant (`'wx'`, `'ax'`, `'xw'`, `'xa'`, etc.) and
|
|
147
|
+
* `filepath` already exists.
|
|
148
|
+
*/
|
|
81
149
|
export function open(
|
|
82
150
|
filepath: Path,
|
|
83
151
|
flags?: Flag | number,
|
|
84
152
|
mode?: string | number
|
|
85
153
|
): Promise<FileHandle>
|
|
86
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Check whether the file at `filepath` is accessible. `mode` defaults to `fs.constants.F_OK`.
|
|
157
|
+
* @param mode - Defaults to `fs.constants.F_OK` (existence only); may also combine `R_OK`, `W_OK`,
|
|
158
|
+
* and/or `X_OK`.
|
|
159
|
+
*/
|
|
87
160
|
export function access(filepath: Path, mode?: number): Promise<void>
|
|
88
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Append `data` to a file, creating it if it does not exist. Accepts the same options as
|
|
164
|
+
* `fs.writeFile()` but defaults to the `'a'` flag.
|
|
165
|
+
*/
|
|
89
166
|
export function appendFile(
|
|
90
167
|
filepath: Path,
|
|
91
168
|
data: string | Buffer | ArrayBufferView,
|
|
@@ -102,24 +179,66 @@ export function chmod(filepath: Path, mode: string | number): Promise<void>
|
|
|
102
179
|
|
|
103
180
|
export function chown(filepath: Path, uid: number, gid: number): Promise<void>
|
|
104
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Copy a file from `src` to `dst`. `mode` is an optional bitmask created from
|
|
184
|
+
* `fs.constants.COPYFILE_EXCL`, `fs.constants.COPYFILE_FICLONE`, or
|
|
185
|
+
* `fs.constants.COPYFILE_FICLONE_FORCE`.
|
|
186
|
+
* @param mode - Defaults to `0`. A bitmask of `fs.constants.COPYFILE_EXCL` (fail if `dst` exists),
|
|
187
|
+
* `COPYFILE_FICLONE`, or `COPYFILE_FICLONE_FORCE`.
|
|
188
|
+
* @throws {EEXIST} `dst` already exists and `mode` includes `fs.constants.COPYFILE_EXCL`.
|
|
189
|
+
*/
|
|
105
190
|
export function copyFile(src: Path, dst: Path, mode?: number): Promise<void>
|
|
106
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Copy a file or directory from `src` to `dst`.
|
|
194
|
+
* @param opts - `recursive` must be `true` to copy a directory; copying a directory without it
|
|
195
|
+
* throws `EISDIR`.
|
|
196
|
+
* @throws {EISDIR} `src` is a directory and `opts.recursive` is not set.
|
|
197
|
+
*/
|
|
107
198
|
export function cp(src: Path, dst: Path, opts?: CpOptions): Promise<void>
|
|
108
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Change the owner and group of a file, but if `filepath` is a symbolic link, the changes are
|
|
202
|
+
* applied only to the link, not the file it refers to.
|
|
203
|
+
*/
|
|
109
204
|
export function lchown(filepath: Path, uid: number, gid: number): Promise<void>
|
|
110
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Like `fs.utimes()`, but if `filepath` is a symbolic link, the timestamps of the link is changed,
|
|
208
|
+
* not the file it refers to.
|
|
209
|
+
*/
|
|
111
210
|
export function lutimes(filepath: Path, atime: number | Date, mtime: number | Date): Promise<void>
|
|
112
211
|
|
|
212
|
+
/** Creates a new link (also known as a hard link) to an existing file. */
|
|
113
213
|
export function link(src: Path, dst: Path): Promise<void>
|
|
114
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Like `fs.stat()`, but if `filepath` is a symbolic link, the link itself is statted, not the file
|
|
217
|
+
* it refers to.
|
|
218
|
+
*/
|
|
115
219
|
export function lstat(filepath: Path): Promise<Stats>
|
|
116
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Create a directory at `filepath`.
|
|
223
|
+
* @param opts - `mode` defaults to `0o777`. `recursive`, if `true`, creates missing parent
|
|
224
|
+
* directories and does not error if `filepath` already exists as a directory.
|
|
225
|
+
* @throws {ENOENT} a parent directory in `filepath` does not exist and `opts.recursive` is not set.
|
|
226
|
+
* @throws {EEXIST} `filepath` already exists; when `opts.recursive` is set this is only thrown if
|
|
227
|
+
* the existing path is not itself a directory.
|
|
228
|
+
*/
|
|
117
229
|
export function mkdir(filepath: Path, opts?: MkdirOptions): Promise<void>
|
|
118
230
|
|
|
119
231
|
export function mkdir(filepath: Path, mode: number): Promise<void>
|
|
120
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Create a unique temporary directory.
|
|
235
|
+
* @param prefix - The literal suffix `'XXXXXX'` is appended to `prefix` and replaced with random
|
|
236
|
+
* characters to form the directory name.
|
|
237
|
+
* @returns The path of the newly created directory, including its randomly generated suffix.
|
|
238
|
+
*/
|
|
121
239
|
export function mkdtemp(prefix: Path): Promise<string>
|
|
122
240
|
|
|
241
|
+
/** Open a directory for iteration. Returns a `Dir` object. */
|
|
123
242
|
export function opendir(
|
|
124
243
|
filepath: Path,
|
|
125
244
|
opts: OpendirOptions & { encoding?: BufferEncoding }
|
|
@@ -140,6 +259,12 @@ export function opendir(filepath: Path, encoding: BufferEncoding | 'buffer'): Pr
|
|
|
140
259
|
|
|
141
260
|
export function opendir(filepath: Path): Promise<Dir<string>>
|
|
142
261
|
|
|
262
|
+
/**
|
|
263
|
+
* Read the entire contents of a file. Returns a `Buffer` by default, or a string if an `encoding`
|
|
264
|
+
* is specified.
|
|
265
|
+
* @param opts - `encoding` defaults to `'buffer'` (returning a `Buffer` rather than a string);
|
|
266
|
+
* `flag` defaults to `'r'`.
|
|
267
|
+
*/
|
|
143
268
|
export function readFile(
|
|
144
269
|
filepath: Path,
|
|
145
270
|
opts: ReadFileOptions & { encoding: BufferEncoding }
|
|
@@ -163,6 +288,12 @@ export function readFile(
|
|
|
163
288
|
|
|
164
289
|
export function readFile(filepath: Path): Promise<Buffer>
|
|
165
290
|
|
|
291
|
+
/**
|
|
292
|
+
* Read the contents of a directory. Returns an array of filenames or, if `withFileTypes` is `true`,
|
|
293
|
+
* an array of `Dirent` objects.
|
|
294
|
+
* @param opts - `withFileTypes`, if `true`, returns `Dirent` objects instead of plain filename
|
|
295
|
+
* strings.
|
|
296
|
+
*/
|
|
166
297
|
export function readdir(
|
|
167
298
|
filepath: Path,
|
|
168
299
|
opts: ReaddirOptions & { encoding?: BufferEncoding }
|
|
@@ -216,6 +347,7 @@ export function readdir(
|
|
|
216
347
|
|
|
217
348
|
export function readdir(filepath: Path): Promise<string[]>
|
|
218
349
|
|
|
350
|
+
/** Read the target of a symbolic link. */
|
|
219
351
|
export function readlink(
|
|
220
352
|
filepath: Path,
|
|
221
353
|
opts: ReadlinkOptions & { encoding?: BufferEncoding }
|
|
@@ -239,6 +371,7 @@ export function readlink(
|
|
|
239
371
|
|
|
240
372
|
export function readlink(filepath: Path): Promise<string>
|
|
241
373
|
|
|
374
|
+
/** Resolve the real path of `filepath`, expanding all symbolic links. */
|
|
242
375
|
export function realpath(
|
|
243
376
|
filepath: Path,
|
|
244
377
|
opts: RealpathOptions & { encoding?: BufferEncoding }
|
|
@@ -262,24 +395,53 @@ export function realpath(
|
|
|
262
395
|
|
|
263
396
|
export function realpath(filepath: Path): Promise<string>
|
|
264
397
|
|
|
398
|
+
/** Rename a file from `src` to `dst`. */
|
|
265
399
|
export function rename(src: Path, dst: Path): Promise<void>
|
|
266
400
|
|
|
401
|
+
/**
|
|
402
|
+
* Remove a file or directory at `filepath`.
|
|
403
|
+
* @param opts - `recursive`, if `true`, removes directories and their contents; `force`, if `true`,
|
|
404
|
+
* suppresses the error when `filepath` does not exist.
|
|
405
|
+
* @throws {EISDIR} `filepath` is a directory and `opts.recursive` is not set.
|
|
406
|
+
*/
|
|
267
407
|
export function rm(filepath: Path, opts?: RmOptions): Promise<void>
|
|
268
408
|
|
|
409
|
+
/**
|
|
410
|
+
* Remove an empty directory.
|
|
411
|
+
* @throws {ENOTEMPTY} the directory is not empty.
|
|
412
|
+
*/
|
|
269
413
|
export function rmdir(filepath: Path): Promise<void>
|
|
270
414
|
|
|
271
415
|
export function stat(filepath: Path): Promise<Stats>
|
|
272
416
|
|
|
417
|
+
/** Get filesystem statistics. Returns a `StatFs` object. */
|
|
273
418
|
export function statfs(filepath: Path): Promise<StatFs>
|
|
274
419
|
|
|
275
420
|
export function truncate(filepath: Path, len?: number): Promise<void>
|
|
276
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Create a symbolic link at `filepath` pointing to `target`. `type` may be `'file'`, `'dir'`, or
|
|
424
|
+
* `'junction'` (Windows only) or a numeric flag. On Windows, if `type` is not provided, it is
|
|
425
|
+
* inferred from the target.
|
|
426
|
+
*/
|
|
277
427
|
export function symlink(target: Path, filepath: Path, type?: string | number): Promise<void>
|
|
278
428
|
|
|
429
|
+
/**
|
|
430
|
+
* Remove a file.
|
|
431
|
+
* @param filepath - The path of the file to remove.
|
|
432
|
+
*/
|
|
279
433
|
export function unlink(filepath: Path): Promise<void>
|
|
280
434
|
|
|
281
435
|
export function utimes(filepath: Path, atime: number | Date, mtime: number | Date): Promise<void>
|
|
282
436
|
|
|
437
|
+
/**
|
|
438
|
+
* Watch a file or directory for changes. Returns a `Watcher` object. The `callback`, if provided,
|
|
439
|
+
* is called with `(eventType, filename)` on each change.
|
|
440
|
+
* @param opts - `persistent` defaults to `true`; `recursive` (default `false`) also watches
|
|
441
|
+
* subdirectories; `encoding` defaults to `'utf8'`.
|
|
442
|
+
* @param cb - Called with `(eventType, filename)` on each change; equivalent to listening for the
|
|
443
|
+
* `Watcher`'s `'change'` event.
|
|
444
|
+
*/
|
|
283
445
|
export function watch(
|
|
284
446
|
filepath: Path,
|
|
285
447
|
opts: WatcherOptions & { encoding?: BufferEncoding }
|
|
@@ -300,6 +462,11 @@ export function watch(filepath: Path, encoding: BufferEncoding | 'buffer'): Watc
|
|
|
300
462
|
|
|
301
463
|
export function watch(filepath: Path): Watcher<string>
|
|
302
464
|
|
|
465
|
+
/**
|
|
466
|
+
* Write `data` to a file, replacing it if it already exists.
|
|
467
|
+
* @param opts - `flag` defaults to `'w'` (truncating any existing file); `mode` defaults to
|
|
468
|
+
* `0o666`.
|
|
469
|
+
*/
|
|
303
470
|
export function writeFile(
|
|
304
471
|
filepath: Path,
|
|
305
472
|
data: string | Buffer | ArrayBufferView,
|