@zenfs/core 0.8.1 → 0.9.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.
@@ -2,10 +2,12 @@ import { Buffer } from 'buffer';
2
2
  import { ApiError, ErrorCode } from '../ApiError.js';
3
3
  import { ActionType, isAppendable, isReadable, isWriteable, parseFlag, pathExistsAction, pathNotExistsAction } from '../file.js';
4
4
  import { BigIntStats, FileType } from '../stats.js';
5
- import { F_OK } from './constants.js';
6
- import { Dirent } from './dir.js';
5
+ import { normalizeMode, normalizeOptions, normalizePath, normalizeTime } from '../utils.js';
6
+ import * as constants from './constants.js';
7
+ import { Dir, Dirent } from './dir.js';
7
8
  import { dirname, join, parse } from './path.js';
8
- import { cred, fd2file, fdMap, fixError, getFdForFile, mounts, normalizeMode, normalizeOptions, normalizePath, normalizeTime, resolveMount } from './shared.js';
9
+ import { cred, fd2file, fdMap, fixError, getFdForFile, mounts, resolveMount } from './shared.js';
10
+ import { ReadStream, WriteStream } from './streams.js';
9
11
  export * as constants from './constants.js';
10
12
  export class FileHandle {
11
13
  constructor(
@@ -15,12 +17,12 @@ export class FileHandle {
15
17
  fd) {
16
18
  this.fd = fd;
17
19
  }
20
+ /**
21
+ * @internal
22
+ */
18
23
  get file() {
19
24
  return fd2file(this.fd);
20
25
  }
21
- get path() {
22
- return this.file.path;
23
- }
24
26
  /**
25
27
  * Asynchronous fchown(2) - Change ownership of a file.
26
28
  */
@@ -128,13 +130,35 @@ export class FileHandle {
128
130
  * @experimental
129
131
  */
130
132
  readableWebStream(options) {
131
- throw ApiError.With('ENOTSUP', this.path, 'FileHandle.readableWebStream');
133
+ // Note: using an arrow function to preserve `this`
134
+ const start = async ({ close, enqueue, error }) => {
135
+ try {
136
+ const chunkSize = 64 * 1024, maxChunks = 1e7;
137
+ let i = 0, position = 0, result;
138
+ while (result.bytesRead > 0) {
139
+ result = await this.read(new Uint8Array(chunkSize), 0, chunkSize, position);
140
+ if (!result.bytesRead) {
141
+ close();
142
+ return;
143
+ }
144
+ enqueue(result.buffer.slice(0, result.bytesRead));
145
+ position += result.bytesRead;
146
+ if (++i >= maxChunks) {
147
+ throw new ApiError(ErrorCode.EFBIG, 'Too many iterations on readable stream', this.file.path, 'FileHandle.readableWebStream');
148
+ }
149
+ }
150
+ }
151
+ catch (e) {
152
+ error(e);
153
+ }
154
+ };
155
+ return new ReadableStream({ start, type: options.type });
132
156
  }
133
157
  readLines(options) {
134
- throw ApiError.With('ENOTSUP', this.path, 'FileHandle.readLines');
158
+ throw ApiError.With('ENOSYS', this.file.path, 'FileHandle.readLines');
135
159
  }
136
160
  [Symbol.asyncDispose]() {
137
- throw ApiError.With('ENOTSUP', this.path, 'FileHandle.@@asyncDispose');
161
+ return this.close();
138
162
  }
139
163
  async stat(opts) {
140
164
  const stats = await this.file.stat();
@@ -191,26 +215,80 @@ export class FileHandle {
191
215
  await this.file.close();
192
216
  fdMap.delete(this.fd);
193
217
  }
194
- /* eslint-disable @typescript-eslint/no-unused-vars */
195
218
  /**
196
- * See `fs.writev` promisified version.
197
- * @todo Implement
219
+ * Asynchronous `writev`. Writes from multiple buffers.
220
+ * @param buffers An array of Uint8Array buffers.
221
+ * @param position The position in the file where to begin writing.
222
+ * @returns The number of bytes written.
198
223
  */
199
- writev(buffers, position) {
200
- throw ApiError.With('ENOTSUP', this.path, 'FileHandle.writev');
224
+ async writev(buffers, position) {
225
+ let bytesWritten = 0;
226
+ for (const buffer of buffers) {
227
+ bytesWritten += (await this.write(buffer, 0, buffer.length, position + bytesWritten)).bytesWritten;
228
+ }
229
+ return { bytesWritten, buffers };
201
230
  }
202
231
  /**
203
- * See `fs.readv` promisified version.
204
- * @todo Implement
232
+ * Asynchronous `readv`. Reads into multiple buffers.
233
+ * @param buffers An array of Uint8Array buffers.
234
+ * @param position The position in the file where to begin reading.
235
+ * @returns The number of bytes read.
205
236
  */
206
- readv(buffers, position) {
207
- throw ApiError.With('ENOTSUP', this.path, 'FileHandle.readv');
237
+ async readv(buffers, position) {
238
+ let bytesRead = 0;
239
+ for (const buffer of buffers) {
240
+ bytesRead += (await this.read(buffer, 0, buffer.byteLength, position + bytesRead)).bytesRead;
241
+ }
242
+ return { bytesRead, buffers };
208
243
  }
244
+ /**
245
+ * Creates a `ReadStream` for reading from the file.
246
+ *
247
+ * @param options Options for the readable stream
248
+ * @returns A `ReadStream` object.
249
+ */
209
250
  createReadStream(options) {
210
- throw ApiError.With('ENOTSUP', this.path, 'createReadStream');
251
+ const streamOptions = {
252
+ highWaterMark: options?.highWaterMark || 64 * 1024,
253
+ encoding: options?.encoding,
254
+ read: async (size) => {
255
+ try {
256
+ const result = await this.read(new Uint8Array(size), 0, size, this.file.position);
257
+ stream.push(!result.bytesRead ? null : result.buffer.slice(0, result.bytesRead)); // Push data or null for EOF
258
+ this.file.position += result.bytesRead;
259
+ }
260
+ catch (error) {
261
+ stream.destroy(error);
262
+ }
263
+ },
264
+ };
265
+ const stream = new ReadStream(streamOptions);
266
+ stream.path = this.file.path;
267
+ return stream;
211
268
  }
269
+ /**
270
+ * Creates a `WriteStream` for writing to the file.
271
+ *
272
+ * @param options Options for the writeable stream.
273
+ * @returns A `WriteStream` object
274
+ */
212
275
  createWriteStream(options) {
213
- throw ApiError.With('ENOTSUP', this.path, 'createWriteStream');
276
+ const streamOptions = {
277
+ highWaterMark: options?.highWaterMark,
278
+ encoding: options?.encoding,
279
+ write: async (chunk, encoding, callback) => {
280
+ try {
281
+ const { bytesWritten } = await this.write(chunk, null, encoding);
282
+ callback(bytesWritten == chunk.length ? null : new Error('Failed to write full chunk'));
283
+ }
284
+ catch (error) {
285
+ callback(error);
286
+ }
287
+ },
288
+ };
289
+ const stream = new WriteStream(streamOptions);
290
+ stream.path = this.file.path;
291
+ return stream;
214
292
  }
215
293
  }
216
294
  /**
@@ -405,7 +483,7 @@ export async function readFile(filename, _options) {
405
483
  }
406
484
  readFile;
407
485
  /**
408
- * Synchronously writes data to a file, replacing the file if it already exists.
486
+ * Asynchronously writes data to a file, replacing the file if it already exists.
409
487
  *
410
488
  * The encoding option is ignored if data is a buffer.
411
489
  * @param filename
@@ -647,7 +725,7 @@ export async function realpath(path, options) {
647
725
  }
648
726
  realpath;
649
727
  export function watch(filename, options) {
650
- throw ApiError.With('ENOTSUP', filename, 'watch');
728
+ throw ApiError.With('ENOSYS', filename, 'watch');
651
729
  }
652
730
  watch;
653
731
  /**
@@ -655,44 +733,126 @@ watch;
655
733
  * @param path
656
734
  * @param mode
657
735
  */
658
- export async function access(path, mode = F_OK) {
736
+ export async function access(path, mode = constants.F_OK) {
659
737
  const stats = await stat(path);
660
738
  if (!stats.hasAccess(mode, cred)) {
661
739
  throw new ApiError(ErrorCode.EACCES);
662
740
  }
663
741
  }
664
742
  access;
665
- /* eslint-disable @typescript-eslint/no-unused-vars */
666
743
  /**
667
- * @todo Implement
744
+ * Asynchronous `rm`. Removes files or directories (recursively).
745
+ * @param path The path to the file or directory to remove.
668
746
  */
669
747
  export async function rm(path, options) {
670
- throw ApiError.With('ENOTSUP', path, 'rm');
748
+ path = normalizePath(path);
749
+ const stats = await stat(path);
750
+ switch (stats.mode & constants.S_IFMT) {
751
+ case constants.S_IFDIR:
752
+ if (options?.recursive) {
753
+ for (const entry of await readdir(path)) {
754
+ await rm(join(path, entry));
755
+ }
756
+ }
757
+ await rmdir(path);
758
+ return;
759
+ case constants.S_IFREG:
760
+ case constants.S_IFLNK:
761
+ await unlink(path);
762
+ return;
763
+ case constants.S_IFBLK:
764
+ case constants.S_IFCHR:
765
+ case constants.S_IFIFO:
766
+ case constants.S_IFSOCK:
767
+ default:
768
+ throw new ApiError(ErrorCode.EPERM, 'File type not supported', path, 'rm');
769
+ }
671
770
  }
672
771
  rm;
673
772
  export async function mkdtemp(prefix, options) {
674
- throw ApiError.With('ENOTSUP', prefix, 'mkdtemp');
773
+ const encoding = typeof options === 'object' ? options.encoding : options || 'utf8';
774
+ const fsName = `${prefix}${Date.now()}-${Math.random().toString(36).slice(2)}`;
775
+ const resolvedPath = '/tmp/' + fsName;
776
+ await mkdir(resolvedPath);
777
+ return encoding == 'buffer' ? Buffer.from(resolvedPath) : resolvedPath;
675
778
  }
676
779
  mkdtemp;
677
780
  /**
678
- * @todo Implement
781
+ * Asynchronous `copyFile`. Copies a file.
782
+ * @param src The source file.
783
+ * @param dest The destination file.
784
+ * @param mode Optional flags for the copy operation. Currently supports these flags:
785
+ * * `fs.constants.COPYFILE_EXCL`: If the destination file already exists, the operation fails.
679
786
  */
680
787
  export async function copyFile(src, dest, mode) {
681
- throw ApiError.With('ENOTSUP', src, 'copyFile');
788
+ src = normalizePath(src);
789
+ dest = normalizePath(dest);
790
+ if (mode && mode & constants.COPYFILE_EXCL && (await exists(dest))) {
791
+ throw new ApiError(ErrorCode.EEXIST, 'Destination file already exists.', dest, 'copyFile');
792
+ }
793
+ await writeFile(dest, await readFile(src));
682
794
  }
683
795
  copyFile;
684
796
  /**
685
- * @todo Implement
797
+ * Asynchronous `opendir`. Opens a directory.
798
+ * @param path The path to the directory.
799
+ * @param options Options for opening the directory.
800
+ * @returns A `Dir` object representing the opened directory.
686
801
  */
687
802
  export async function opendir(path, options) {
688
- throw ApiError.With('ENOTSUP', path, 'opendir');
803
+ path = normalizePath(path);
804
+ return new Dir(path);
689
805
  }
690
806
  opendir;
807
+ /**
808
+ * Asynchronous `cp`. Recursively copies a file or directory.
809
+ * @param source The source file or directory.
810
+ * @param destination The destination file or directory.
811
+ * @param opts Options for the copy operation. Currently supports these options from Node.js 'fs.await cp':
812
+ * * `dereference`: Dereference symbolic links.
813
+ * * `errorOnExist`: Throw an error if the destination file or directory already exists.
814
+ * * `filter`: A function that takes a source and destination path and returns a boolean, indicating whether to copy the given source element.
815
+ * * `force`: Overwrite the destination if it exists, and overwrite existing readonly destination files.
816
+ * * `preserveTimestamps`: Preserve file timestamps.
817
+ * * `recursive`: If `true`, copies directories recursively.
818
+ */
691
819
  export async function cp(source, destination, opts) {
692
- throw ApiError.With('ENOTSUP', source, 'cp');
820
+ source = normalizePath(source);
821
+ destination = normalizePath(destination);
822
+ const srcStats = await lstat(source); // Use lstat to follow symlinks if not dereferencing
823
+ if (opts?.errorOnExist && (await exists(destination))) {
824
+ throw new ApiError(ErrorCode.EEXIST, 'Destination file or directory already exists.', destination, 'cp');
825
+ }
826
+ switch (srcStats.mode & constants.S_IFMT) {
827
+ case constants.S_IFDIR:
828
+ if (!opts?.recursive) {
829
+ throw new ApiError(ErrorCode.EISDIR, source + ' is a directory (not copied)', source, 'cp');
830
+ }
831
+ await mkdir(destination, { recursive: true }); // Ensure the destination directory exists
832
+ for (const dirent of await readdir(source, { withFileTypes: true })) {
833
+ if (opts.filter && !opts.filter(join(source, dirent.name), join(destination, dirent.name))) {
834
+ continue; // Skip if the filter returns false
835
+ }
836
+ await cp(join(source, dirent.name), join(destination, dirent.name), opts);
837
+ }
838
+ break;
839
+ case constants.S_IFREG:
840
+ case constants.S_IFLNK:
841
+ await copyFile(source, destination);
842
+ break;
843
+ case constants.S_IFBLK:
844
+ case constants.S_IFCHR:
845
+ case constants.S_IFIFO:
846
+ case constants.S_IFSOCK:
847
+ default:
848
+ throw new ApiError(ErrorCode.EPERM, 'File type not supported', source, 'rm');
849
+ }
850
+ // Optionally preserve timestamps
851
+ if (opts?.preserveTimestamps) {
852
+ await utimes(destination, srcStats.atime, srcStats.mtime);
853
+ }
693
854
  }
694
855
  cp;
695
856
  export async function statfs(path, opts) {
696
- throw ApiError.With('ENOTSUP', path, 'statfs');
857
+ throw ApiError.With('ENOSYS', path, 'statfs');
697
858
  }
698
- /* eslint-enable @typescript-eslint/no-unused-vars */
@@ -1,51 +1,6 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
1
  import { Cred } from '../cred.js';
4
- import { FileSystem } from '../filesystem.js';
5
2
  import type { File } from '../file.js';
6
- import type { EncodingOption, OpenMode, WriteFileOptions } from 'node:fs';
7
- /**
8
- * converts Date or number to a integer UNIX timestamp
9
- * Grabbed from NodeJS sources (lib/fs.js)
10
- *
11
- * @internal
12
- */
13
- export declare function _toUnixTimestamp(time: Date | number): number;
14
- /**
15
- * Normalizes a mode
16
- * @internal
17
- */
18
- export declare function normalizeMode(mode: string | number | unknown, def?: number): number;
19
- /**
20
- * Normalizes a time
21
- * @internal
22
- */
23
- export declare function normalizeTime(time: string | number | Date): Date;
24
- /**
25
- * Normalizes a path
26
- * @internal
27
- */
28
- export declare function normalizePath(p: string): string;
29
- /**
30
- * Normalizes options
31
- * @param options options to normalize
32
- * @param encoding default encoding
33
- * @param flag default flag
34
- * @param mode default mode
35
- * @internal
36
- */
37
- export declare function normalizeOptions(options?: WriteFileOptions | (EncodingOption & {
38
- flag?: OpenMode;
39
- }), encoding?: BufferEncoding, flag?: string, mode?: number): {
40
- encoding: BufferEncoding;
41
- flag: string;
42
- mode: number;
43
- };
44
- /**
45
- * Do nothing
46
- * @internal
47
- */
48
- export declare function nop(): void;
3
+ import { FileSystem } from '../filesystem.js';
49
4
  export declare let cred: Cred;
50
5
  export declare function setCred(val: Cred): void;
51
6
  export declare const fdMap: Map<number, File>;
@@ -1,101 +1,9 @@
1
1
  // Utilities and shared data
2
- import { resolve } from './path.js';
3
2
  import { ApiError, ErrorCode } from '../ApiError.js';
4
- import { rootCred } from '../cred.js';
5
3
  import { InMemory } from '../backends/InMemory.js';
6
- /**
7
- * converts Date or number to a integer UNIX timestamp
8
- * Grabbed from NodeJS sources (lib/fs.js)
9
- *
10
- * @internal
11
- */
12
- export function _toUnixTimestamp(time) {
13
- if (typeof time === 'number') {
14
- return Math.floor(time);
15
- }
16
- if (time instanceof Date) {
17
- return Math.floor(time.getTime() / 1000);
18
- }
19
- throw new Error('Cannot parse time: ' + time);
20
- }
21
- /**
22
- * Normalizes a mode
23
- * @internal
24
- */
25
- export function normalizeMode(mode, def) {
26
- if (typeof mode == 'number') {
27
- return mode;
28
- }
29
- if (typeof mode == 'string') {
30
- const parsed = parseInt(mode, 8);
31
- if (!isNaN(parsed)) {
32
- return parsed;
33
- }
34
- }
35
- if (typeof def == 'number') {
36
- return def;
37
- }
38
- throw new ApiError(ErrorCode.EINVAL, 'Invalid mode: ' + mode?.toString());
39
- }
40
- /**
41
- * Normalizes a time
42
- * @internal
43
- */
44
- export function normalizeTime(time) {
45
- if (time instanceof Date) {
46
- return time;
47
- }
48
- if (typeof time == 'number') {
49
- return new Date(time * 1000);
50
- }
51
- if (typeof time == 'string') {
52
- return new Date(time);
53
- }
54
- throw new ApiError(ErrorCode.EINVAL, 'Invalid time.');
55
- }
56
- /**
57
- * Normalizes a path
58
- * @internal
59
- */
60
- export function normalizePath(p) {
61
- // Node doesn't allow null characters in paths.
62
- if (p.includes('\x00')) {
63
- throw new ApiError(ErrorCode.EINVAL, 'Path must be a string without null bytes.');
64
- }
65
- if (p.length == 0) {
66
- throw new ApiError(ErrorCode.EINVAL, 'Path must not be empty.');
67
- }
68
- return resolve(p.replaceAll(/[/\\]+/g, '/'));
69
- }
70
- /**
71
- * Normalizes options
72
- * @param options options to normalize
73
- * @param encoding default encoding
74
- * @param flag default flag
75
- * @param mode default mode
76
- * @internal
77
- */
78
- export function normalizeOptions(options, encoding = 'utf8', flag, mode = 0) {
79
- if (typeof options != 'object' || options === null) {
80
- return {
81
- encoding: typeof options == 'string' ? options : encoding,
82
- flag,
83
- mode,
84
- };
85
- }
86
- return {
87
- encoding: typeof options?.encoding == 'string' ? options.encoding : encoding,
88
- flag: typeof options?.flag == 'string' ? options.flag : flag,
89
- mode: normalizeMode('mode' in options ? options?.mode : null, mode),
90
- };
91
- }
92
- /**
93
- * Do nothing
94
- * @internal
95
- */
96
- export function nop() {
97
- // do nothing
98
- }
4
+ import { rootCred } from '../cred.js';
5
+ import { normalizePath } from '../utils.js';
6
+ import { resolve } from './path.js';
99
7
  // credentials
100
8
  export let cred = rootCred;
101
9
  export function setCred(val) {
@@ -8,100 +8,10 @@ export declare class ReadStream extends Readable implements Node.ReadStream {
8
8
  bytesRead: number;
9
9
  path: string | Buffer;
10
10
  pending: boolean;
11
- addListener(event: 'close', listener: () => void): this;
12
- addListener(event: 'data', listener: (chunk: Buffer | string) => void): this;
13
- addListener(event: 'end', listener: () => void): this;
14
- addListener(event: 'error', listener: (err: Error) => void): this;
15
- addListener(event: 'open', listener: (fd: number) => void): this;
16
- addListener(event: 'pause', listener: () => void): this;
17
- addListener(event: 'readable', listener: () => void): this;
18
- addListener(event: 'ready', listener: () => void): this;
19
- addListener(event: 'resume', listener: () => void): this;
20
- on(event: 'close', listener: () => void): this;
21
- on(event: 'data', listener: (chunk: Buffer | string) => void): this;
22
- on(event: 'end', listener: () => void): this;
23
- on(event: 'error', listener: (err: Error) => void): this;
24
- on(event: 'open', listener: (fd: number) => void): this;
25
- on(event: 'pause', listener: () => void): this;
26
- on(event: 'readable', listener: () => void): this;
27
- on(event: 'ready', listener: () => void): this;
28
- on(event: 'resume', listener: () => void): this;
29
- once(event: 'close', listener: () => void): this;
30
- once(event: 'data', listener: (chunk: Buffer | string) => void): this;
31
- once(event: 'end', listener: () => void): this;
32
- once(event: 'error', listener: (err: Error) => void): this;
33
- once(event: 'open', listener: (fd: number) => void): this;
34
- once(event: 'pause', listener: () => void): this;
35
- once(event: 'readable', listener: () => void): this;
36
- once(event: 'ready', listener: () => void): this;
37
- once(event: 'resume', listener: () => void): this;
38
- prependListener(event: 'close', listener: () => void): this;
39
- prependListener(event: 'data', listener: (chunk: Buffer | string) => void): this;
40
- prependListener(event: 'end', listener: () => void): this;
41
- prependListener(event: 'error', listener: (err: Error) => void): this;
42
- prependListener(event: 'open', listener: (fd: number) => void): this;
43
- prependListener(event: 'pause', listener: () => void): this;
44
- prependListener(event: 'readable', listener: () => void): this;
45
- prependListener(event: 'ready', listener: () => void): this;
46
- prependListener(event: 'resume', listener: () => void): this;
47
- prependOnceListener(event: 'close', listener: () => void): this;
48
- prependOnceListener(event: 'data', listener: (chunk: Buffer | string) => void): this;
49
- prependOnceListener(event: 'end', listener: () => void): this;
50
- prependOnceListener(event: 'error', listener: (err: Error) => void): this;
51
- prependOnceListener(event: 'open', listener: (fd: number) => void): this;
52
- prependOnceListener(event: 'pause', listener: () => void): this;
53
- prependOnceListener(event: 'readable', listener: () => void): this;
54
- prependOnceListener(event: 'ready', listener: () => void): this;
55
- prependOnceListener(event: 'resume', listener: () => void): this;
56
11
  }
57
12
  export declare class WriteStream extends Writable implements Node.WriteStream {
58
13
  close(callback?: Callback): void;
59
14
  bytesWritten: number;
60
15
  path: string | Buffer;
61
16
  pending: boolean;
62
- addListener(event: 'close', listener: () => void): this;
63
- addListener(event: 'drain', listener: () => void): this;
64
- addListener(event: 'error', listener: (err: Error) => void): this;
65
- addListener(event: 'finish', listener: () => void): this;
66
- addListener(event: 'open', listener: (fd: number) => void): this;
67
- addListener(event: 'pipe', listener: (src: Readable) => void): this;
68
- addListener(event: 'ready', listener: () => void): this;
69
- addListener(event: 'unpipe', listener: (src: Readable) => void): this;
70
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
71
- on(event: 'close', listener: () => void): this;
72
- on(event: 'drain', listener: () => void): this;
73
- on(event: 'error', listener: (err: Error) => void): this;
74
- on(event: 'finish', listener: () => void): this;
75
- on(event: 'open', listener: (fd: number) => void): this;
76
- on(event: 'pipe', listener: (src: Readable) => void): this;
77
- on(event: 'ready', listener: () => void): this;
78
- on(event: 'unpipe', listener: (src: Readable) => void): this;
79
- on(event: string | symbol, listener: (...args: any[]) => void): this;
80
- once(event: 'close', listener: () => void): this;
81
- once(event: 'drain', listener: () => void): this;
82
- once(event: 'error', listener: (err: Error) => void): this;
83
- once(event: 'finish', listener: () => void): this;
84
- once(event: 'open', listener: (fd: number) => void): this;
85
- once(event: 'pipe', listener: (src: Readable) => void): this;
86
- once(event: 'ready', listener: () => void): this;
87
- once(event: 'unpipe', listener: (src: Readable) => void): this;
88
- once(event: string | symbol, listener: (...args: any[]) => void): this;
89
- prependListener(event: 'close', listener: () => void): this;
90
- prependListener(event: 'drain', listener: () => void): this;
91
- prependListener(event: 'error', listener: (err: Error) => void): this;
92
- prependListener(event: 'finish', listener: () => void): this;
93
- prependListener(event: 'open', listener: (fd: number) => void): this;
94
- prependListener(event: 'pipe', listener: (src: Readable) => void): this;
95
- prependListener(event: 'ready', listener: () => void): this;
96
- prependListener(event: 'unpipe', listener: (src: Readable) => void): this;
97
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
98
- prependOnceListener(event: 'close', listener: () => void): this;
99
- prependOnceListener(event: 'drain', listener: () => void): this;
100
- prependOnceListener(event: 'error', listener: (err: Error) => void): this;
101
- prependOnceListener(event: 'finish', listener: () => void): this;
102
- prependOnceListener(event: 'open', listener: (fd: number) => void): this;
103
- prependOnceListener(event: 'pipe', listener: (src: Readable) => void): this;
104
- prependOnceListener(event: 'ready', listener: () => void): this;
105
- prependOnceListener(event: 'unpipe', listener: (src: Readable) => void): this;
106
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
107
17
  }
@@ -10,21 +10,6 @@ export class ReadStream extends Readable {
10
10
  callback(err);
11
11
  }
12
12
  }
13
- addListener(event, listener) {
14
- return super.addListener(event, listener);
15
- }
16
- on(event, listener) {
17
- return super.on(event, listener);
18
- }
19
- once(event, listener) {
20
- return super.once(event, listener);
21
- }
22
- prependListener(event, listener) {
23
- return super.prependListener(event, listener);
24
- }
25
- prependOnceListener(event, listener) {
26
- return super.prependOnceListener(event, listener);
27
- }
28
13
  }
29
14
  export class WriteStream extends Writable {
30
15
  close(callback = () => null) {
@@ -37,19 +22,4 @@ export class WriteStream extends Writable {
37
22
  callback(err);
38
23
  }
39
24
  }
40
- addListener(event, listener) {
41
- return super.addListener(event, listener);
42
- }
43
- on(event, listener) {
44
- return super.on(event, listener);
45
- }
46
- once(event, listener) {
47
- return super.once(event, listener);
48
- }
49
- prependListener(event, listener) {
50
- return super.prependListener(event, listener);
51
- }
52
- prependOnceListener(event, listener) {
53
- return super.prependOnceListener(event, listener);
54
- }
55
25
  }