@zenfs/core 1.2.0 → 1.2.2

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.
Files changed (52) hide show
  1. package/dist/config.d.ts +13 -4
  2. package/dist/config.js +2 -1
  3. package/dist/emulation/cache.d.ts +14 -2
  4. package/dist/emulation/cache.js +25 -0
  5. package/dist/emulation/config.d.ts +10 -0
  6. package/dist/emulation/config.js +10 -0
  7. package/dist/emulation/promises.js +24 -13
  8. package/dist/emulation/shared.d.ts +0 -6
  9. package/dist/emulation/shared.js +0 -6
  10. package/dist/emulation/sync.js +13 -12
  11. package/dist/file.d.ts +1 -1
  12. package/dist/file.js +6 -3
  13. package/package.json +1 -1
  14. package/readme.md +1 -1
  15. package/scripts/test.js +5 -0
  16. package/src/config.ts +17 -5
  17. package/src/emulation/cache.ts +32 -3
  18. package/src/emulation/config.ts +11 -0
  19. package/src/emulation/promises.ts +25 -13
  20. package/src/emulation/shared.ts +0 -7
  21. package/src/emulation/sync.ts +13 -12
  22. package/src/file.ts +4 -3
  23. package/tests/common.ts +1 -11
  24. package/tests/fs/appendFile.test.ts +3 -3
  25. package/tests/fs/dir.test.ts +7 -7
  26. package/tests/fs/directory.test.ts +8 -8
  27. package/tests/fs/errors.test.ts +1 -1
  28. package/tests/fs/links.test.ts +4 -4
  29. package/tests/fs/open.test.ts +3 -3
  30. package/tests/fs/permissions.test.ts +5 -5
  31. package/tests/fs/read.test.ts +5 -5
  32. package/tests/fs/readFile.test.ts +2 -2
  33. package/tests/fs/rename.test.ts +5 -5
  34. package/tests/fs/stat.test.ts +1 -1
  35. package/tests/fs/streams.test.ts +19 -19
  36. package/tests/fs/times.test.ts +6 -6
  37. package/tests/fs/truncate.test.ts +1 -1
  38. package/tests/fs/watch.test.ts +10 -10
  39. package/tests/fs/write.test.ts +5 -5
  40. package/tests/fs/writeFile.test.ts +5 -5
  41. package/tests/handle.test.ts +2 -2
  42. package/tests/mutex.test.ts +1 -1
  43. package/tests/port/channel.test.ts +3 -3
  44. package/tests/port/config.test.ts +4 -5
  45. package/tests/port/config.worker.js +5 -0
  46. package/tests/port/remote.test.ts +4 -5
  47. package/tests/port/remote.worker.js +5 -0
  48. package/tests/port/timeout.test.ts +4 -4
  49. package/tests/setup/common.ts +1 -1
  50. package/tests/setup/cow+fetch.ts +1 -1
  51. package/tests/port/config.worker.ts +0 -5
  52. package/tests/port/remote.worker.ts +0 -5
@@ -9,7 +9,8 @@ import { decodeUTF8, normalizeMode, normalizeOptions, normalizePath, normalizeTi
9
9
  import * as constants from './constants.js';
10
10
  import { Dir, Dirent } from './dir.js';
11
11
  import { dirname, join, parse } from './path.js';
12
- import { _statfs, config, fd2file, fdMap, file2fd, fixError, mounts, resolveMount, type InternalOptions, type ReaddirOptions } from './shared.js';
12
+ import { _statfs, fd2file, fdMap, file2fd, fixError, mounts, resolveMount, type InternalOptions, type ReaddirOptions } from './shared.js';
13
+ import { config } from './config.js';
13
14
  import { emitChange } from './watchers.js';
14
15
  import * as cache from './cache.js';
15
16
 
@@ -105,7 +106,7 @@ export function unlinkSync(path: fs.PathLike): void {
105
106
  path = normalizePath(path);
106
107
  const { fs, path: resolved } = resolveMount(path);
107
108
  try {
108
- if (config.checkAccess && !(cache.getStats(path) || fs.statSync(resolved)).hasAccess(constants.W_OK)) {
109
+ if (config.checkAccess && !(cache.getStatsSync(path) || fs.statSync(resolved)).hasAccess(constants.W_OK)) {
109
110
  throw ErrnoError.With('EACCES', resolved, 'unlink');
110
111
  }
111
112
  fs.unlinkSync(resolved);
@@ -386,7 +387,7 @@ export function rmdirSync(path: fs.PathLike): void {
386
387
  path = normalizePath(path);
387
388
  const { fs, path: resolved } = resolveMount(realpathSync(path));
388
389
  try {
389
- const stats = cache.getStats(path) || fs.statSync(resolved);
390
+ const stats = cache.getStatsSync(path) || fs.statSync(resolved);
390
391
  if (!stats.isDirectory()) {
391
392
  throw ErrnoError.With('ENOTDIR', resolved, 'rmdir');
392
393
  }
@@ -459,8 +460,8 @@ export function readdirSync(
459
460
  const { fs, path: resolved } = resolveMount(realpathSync(path));
460
461
  let entries: string[];
461
462
  try {
462
- const stats = cache.getStats(path) || fs.statSync(resolved);
463
- cache.setStats(path, stats);
463
+ const stats = cache.getStatsSync(path) || fs.statSync(resolved);
464
+ cache.setStatsSync(path, stats);
464
465
  if (config.checkAccess && !stats.hasAccess(constants.R_OK)) {
465
466
  throw ErrnoError.With('EACCES', resolved, 'readdir');
466
467
  }
@@ -487,8 +488,8 @@ export function readdirSync(
487
488
  // Iterate over entries and handle recursive case if needed
488
489
  const values: (string | Dirent | Buffer)[] = [];
489
490
  for (const entry of entries) {
490
- const entryStat = cache.getStats(join(path, entry)) || fs.statSync(join(resolved, entry));
491
- cache.setStats(join(path, entry), entryStat);
491
+ const entryStat = cache.getStatsSync(join(path, entry)) || fs.statSync(join(resolved, entry));
492
+ cache.setStatsSync(join(path, entry), entryStat);
492
493
 
493
494
  if (options?.withFileTypes) {
494
495
  values.push(new Dirent(entry, entryStat));
@@ -512,7 +513,7 @@ export function readdirSync(
512
513
  }
513
514
 
514
515
  if (!options?._isIndirect) {
515
- cache.clearStats();
516
+ cache.clearStatsSync();
516
517
  }
517
518
  return values as string[] | Dirent[] | Buffer[];
518
519
  }
@@ -670,7 +671,7 @@ export function rmSync(path: fs.PathLike, options?: fs.RmOptions & InternalOptio
670
671
 
671
672
  let stats: Stats | undefined;
672
673
  try {
673
- stats = cache.getStats(path) || statSync(path);
674
+ stats = cache.getStatsSync(path) || statSync(path);
674
675
  } catch (error) {
675
676
  if ((error as ErrnoError).code != 'ENOENT' || !options?.force) throw error;
676
677
  }
@@ -679,7 +680,7 @@ export function rmSync(path: fs.PathLike, options?: fs.RmOptions & InternalOptio
679
680
  return;
680
681
  }
681
682
 
682
- cache.setStats(path, stats);
683
+ cache.setStatsSync(path, stats);
683
684
 
684
685
  switch (stats.mode & constants.S_IFMT) {
685
686
  case constants.S_IFDIR:
@@ -700,12 +701,12 @@ export function rmSync(path: fs.PathLike, options?: fs.RmOptions & InternalOptio
700
701
  case constants.S_IFIFO:
701
702
  case constants.S_IFSOCK:
702
703
  default:
703
- cache.clearStats();
704
+ cache.clearStatsSync();
704
705
  throw new ErrnoError(Errno.EPERM, 'File type not supported', path, 'rm');
705
706
  }
706
707
 
707
708
  if (!options?._isIndirect) {
708
- cache.clearStats();
709
+ cache.clearStatsSync();
709
710
  }
710
711
  }
711
712
  rmSync satisfies typeof fs.rmSync;
package/src/file.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import type { FileReadResult } from 'node:fs/promises';
2
2
  import { O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY, S_IFMT, size_max } from './emulation/constants.js';
3
+ import { config } from './emulation/config.js';
3
4
  import { Errno, ErrnoError } from './error.js';
4
5
  import type { FileSystem } from './filesystem.js';
5
- import { Stats, type FileType } from './stats.js';
6
6
  import './polyfills.js';
7
+ import { Stats, type FileType } from './stats.js';
7
8
 
8
9
  /**
9
10
  Typescript does not include a type declaration for resizable array buffers.
@@ -541,7 +542,7 @@ export class PreloadFile<FS extends FileSystem> extends File {
541
542
  */
542
543
  public async read<TBuffer extends ArrayBufferView>(buffer: TBuffer, offset?: number, length?: number, position?: number): Promise<{ bytesRead: number; buffer: TBuffer }> {
543
544
  const bytesRead = this._read(buffer, offset, length, position);
544
- await this.sync();
545
+ if (config.syncOnRead) await this.sync();
545
546
  return { bytesRead, buffer };
546
547
  }
547
548
 
@@ -556,7 +557,7 @@ export class PreloadFile<FS extends FileSystem> extends File {
556
557
  */
557
558
  public readSync(buffer: ArrayBufferView, offset?: number, length?: number, position?: number): number {
558
559
  const bytesRead = this._read(buffer, offset, length, position);
559
- this.statSync();
560
+ if (config.syncOnRead) this.syncSync();
560
561
  return bytesRead;
561
562
  }
562
563
 
package/tests/common.ts CHANGED
@@ -1,15 +1,5 @@
1
1
  import { join, resolve } from 'node:path';
2
- import { Worker } from 'node:worker_threads';
3
- import { fs } from '../src/index.js';
4
-
5
- /**
6
- * Creates a Typescript Worker
7
- * @see https://github.com/privatenumber/tsx/issues/354
8
- * @see https://github.com/nodejs/node/issues/47747#issuecomment-2287745567
9
- */
10
- export function createTSWorker(source: string): Worker {
11
- return new Worker(`import('tsx/esm/api').then(tsx => {tsx.register();import('${source}');});`, { eval: true });
12
- }
2
+ import { fs } from '../dist/index.js';
13
3
 
14
4
  const setupPath = resolve(process.env.SETUP || join(import.meta.dirname, 'setup/memory.ts'));
15
5
 
@@ -10,7 +10,7 @@ suite('appendFile', () => {
10
10
  const filename = 'append.txt';
11
11
  await fs.promises.appendFile(filename, content);
12
12
  const data = await fs.promises.readFile(filename, 'utf8');
13
- assert(data == content);
13
+ assert.equal(data, content);
14
14
  });
15
15
 
16
16
  test('append data to a non-empty file', async () => {
@@ -19,7 +19,7 @@ suite('appendFile', () => {
19
19
  await fs.promises.writeFile(filename, original);
20
20
  await fs.promises.appendFile(filename, content);
21
21
  const data = await fs.promises.readFile(filename, 'utf8');
22
- assert(data == original + content);
22
+ assert.equal(data, original + content);
23
23
  });
24
24
 
25
25
  test('append a buffer to the file', async () => {
@@ -28,6 +28,6 @@ suite('appendFile', () => {
28
28
  await fs.promises.writeFile(filename, original);
29
29
  await fs.promises.appendFile(filename, content);
30
30
  const data = await fs.promises.readFile(filename, 'utf8');
31
- assert(data == original + content);
31
+ assert.equal(data, original + content);
32
32
  });
33
33
  });
@@ -18,8 +18,8 @@ suite('Dirent', () => {
18
18
  const stats = await fs.promises.lstat(testFile);
19
19
  const dirent = new fs.Dirent(testFile, stats);
20
20
 
21
- assert(dirent.name === testFile);
22
- assert(dirent.parentPath === testFile);
21
+ assert.equal(dirent.name, testFile);
22
+ assert.equal(dirent.parentPath, testFile);
23
23
  });
24
24
 
25
25
  test('Dirent.isFile', async () => {
@@ -68,7 +68,7 @@ suite('Dir', () => {
68
68
  assert(testFiles.includes(dirent2?.name));
69
69
 
70
70
  const dirent3 = await dir.read();
71
- assert(dirent3 === null);
71
+ assert.strictEqual(dirent3, null);
72
72
 
73
73
  await dir.close();
74
74
  });
@@ -76,8 +76,8 @@ suite('Dir', () => {
76
76
  test('Dir read() method (Callback varient)', (_, done) => {
77
77
  const dir = new fs.Dir(testDirPath);
78
78
  dir.read((err, dirent) => {
79
- assert(err === undefined);
80
- assert(dirent != undefined);
79
+ assert.strictEqual(err, undefined);
80
+ assert.notEqual(dirent, undefined);
81
81
  assert(dirent instanceof fs.Dirent);
82
82
  assert(testFiles.includes(dirent?.name));
83
83
  dir.closeSync();
@@ -97,7 +97,7 @@ suite('Dir', () => {
97
97
  assert(testFiles.includes(dirent2?.name));
98
98
 
99
99
  const dirent3 = dir.readSync();
100
- assert(dirent3 === null);
100
+ assert.strictEqual(dirent3, null);
101
101
 
102
102
  dir.closeSync();
103
103
  });
@@ -122,7 +122,7 @@ suite('Dir', () => {
122
122
  dirents.push(dirent);
123
123
  }
124
124
 
125
- assert(dirents.length === 2);
125
+ assert.strictEqual(dirents.length, 2);
126
126
  assert(dirents[0] instanceof fs.Dirent);
127
127
  assert(testFiles.includes(dirents[0].name));
128
128
  assert(testFiles.includes(dirents[1].name));
@@ -1,6 +1,6 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
- import { ErrnoError } from '../../src/error.js';
3
+ import { ErrnoError } from '../../dist/error.js';
4
4
  import { fs } from '../common.js';
5
5
 
6
6
  suite('Directory', () => {
@@ -17,7 +17,7 @@ suite('Directory', () => {
17
17
  await fs.promises.mkdir('/nested/dir');
18
18
  } catch (error: any) {
19
19
  assert(error instanceof ErrnoError);
20
- assert(error.code === 'ENOENT');
20
+ assert.strictEqual(error.code, 'ENOENT');
21
21
  }
22
22
  assert(!(await fs.promises.exists('/nested/dir')));
23
23
  });
@@ -51,7 +51,7 @@ suite('Directory', () => {
51
51
  fs.readdirSync('/two');
52
52
  } catch (error: any) {
53
53
  assert(error instanceof ErrnoError);
54
- assert(error.code === 'EACCES');
54
+ assert.strictEqual(error.code, 'EACCES');
55
55
  }
56
56
  });
57
57
 
@@ -63,7 +63,7 @@ suite('Directory', () => {
63
63
  await fs.promises.rmdir('/rmdirTest');
64
64
  } catch (error: any) {
65
65
  assert(error instanceof ErrnoError);
66
- assert(error.code === 'ENOTEMPTY');
66
+ assert.strictEqual(error.code, 'ENOTEMPTY');
67
67
  }
68
68
  });
69
69
 
@@ -75,7 +75,7 @@ suite('Directory', () => {
75
75
  } catch (error: any) {
76
76
  assert(error instanceof ErrnoError);
77
77
  wasThrown = true;
78
- assert(error.code === 'ENOTDIR');
78
+ assert.strictEqual(error.code, 'ENOTDIR');
79
79
  }
80
80
  assert(wasThrown);
81
81
  });
@@ -85,7 +85,7 @@ suite('Directory', () => {
85
85
  await fs.promises.readdir('a.js');
86
86
  } catch (error: any) {
87
87
  assert(error instanceof ErrnoError);
88
- assert(error.code === 'ENOTDIR');
88
+ assert.strictEqual(error.code, 'ENOTDIR');
89
89
  }
90
90
  });
91
91
 
@@ -97,7 +97,7 @@ suite('Directory', () => {
97
97
  } catch (error: any) {
98
98
  assert(error instanceof ErrnoError);
99
99
  wasThrown = true;
100
- assert(error.code === 'ENOENT');
100
+ assert.strictEqual(error.code, 'ENOENT');
101
101
  }
102
102
  assert(wasThrown);
103
103
  });
@@ -107,7 +107,7 @@ suite('Directory', () => {
107
107
  await fs.promises.readdir('/does/not/exist');
108
108
  } catch (error: any) {
109
109
  assert(error instanceof ErrnoError);
110
- assert(error.code === 'ENOENT');
110
+ assert.strictEqual(error.code, 'ENOENT');
111
111
  }
112
112
  });
113
113
 
@@ -1,6 +1,6 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
- import { ErrnoError } from '../../src/error.js';
3
+ import { ErrnoError } from '../../dist/error.js';
4
4
  import { fs } from '../common.js';
5
5
 
6
6
  const existingFile = '/exit.js';
@@ -1,6 +1,6 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
- import { join } from '../../src/emulation/path.js';
3
+ import { join } from '../../dist/emulation/path.js';
4
4
  import { fs } from '../common.js';
5
5
 
6
6
  suite('Links', () => {
@@ -19,7 +19,7 @@ suite('Links', () => {
19
19
 
20
20
  test('readlink', async () => {
21
21
  const destination = await fs.promises.readlink(symlink);
22
- assert(destination === target);
22
+ assert.strictEqual(destination, target);
23
23
  });
24
24
 
25
25
  test('unlink', async () => {
@@ -32,7 +32,7 @@ suite('Links', () => {
32
32
  await fs.promises.link(target, hardlink);
33
33
  const targetContent = await fs.promises.readFile(target, 'utf8');
34
34
  const linkContent = await fs.promises.readFile(hardlink, 'utf8');
35
- assert(targetContent === linkContent);
35
+ assert.strictEqual(targetContent, linkContent);
36
36
  });
37
37
 
38
38
  test('file inside symlinked directory', async () => {
@@ -41,6 +41,6 @@ suite('Links', () => {
41
41
  const link = join('link', target);
42
42
  assert((await fs.promises.realpath(link)) === target);
43
43
  const linkContent = await fs.promises.readFile(link, 'utf8');
44
- assert(targetContent === linkContent);
44
+ assert.strictEqual(targetContent, linkContent);
45
45
  });
46
46
  });
@@ -1,6 +1,6 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
- import { ErrnoError } from '../../src/error.js';
3
+ import { ErrnoError } from '../../dist/error.js';
4
4
  import { fs } from '../common.js';
5
5
 
6
6
  suite('fs file opening', () => {
@@ -12,7 +12,7 @@ suite('fs file opening', () => {
12
12
  fs.openSync('/path/to/file/that/does/not/exist', 'r');
13
13
  } catch (error: any) {
14
14
  assert(error instanceof ErrnoError);
15
- assert(error?.code === 'ENOENT');
15
+ assert.strictEqual(error?.code, 'ENOENT');
16
16
  caughtException = true;
17
17
  }
18
18
  assert(caughtException);
@@ -23,7 +23,7 @@ suite('fs file opening', () => {
23
23
  await fs.promises.open('/path/to/file/that/does/not/exist', 'r');
24
24
  } catch (error: any) {
25
25
  assert(error instanceof ErrnoError);
26
- assert(error?.code === 'ENOENT');
26
+ assert.strictEqual(error?.code, 'ENOENT');
27
27
  }
28
28
  });
29
29
 
@@ -1,16 +1,16 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
- import { R_OK, W_OK, X_OK } from '../../src/emulation/constants.js';
4
- import { join } from '../../src/emulation/path.js';
5
- import { ErrnoError } from '../../src/error.js';
6
- import { encodeUTF8 } from '../../src/utils.js';
3
+ import { R_OK, W_OK, X_OK } from '../../dist/emulation/constants.js';
4
+ import { join } from '../../dist/emulation/path.js';
5
+ import { ErrnoError } from '../../dist/error.js';
6
+ import { encodeUTF8 } from '../../dist/utils.js';
7
7
  import { fs } from '../common.js';
8
8
 
9
9
  suite('Permissions', () => {
10
10
  async function test_item(path: string): Promise<void> {
11
11
  const stats = await fs.promises.stat(path).catch((error: ErrnoError) => {
12
12
  assert(error instanceof ErrnoError);
13
- assert(error.code === 'EACCES');
13
+ assert.strictEqual(error.code, 'EACCES');
14
14
  });
15
15
  if (!stats) {
16
16
  return;
@@ -10,7 +10,7 @@ suite('read', () => {
10
10
  const handle = await fs.promises.open(filepath, 'r');
11
11
  const { bytesRead, buffer } = await handle.read(Buffer.alloc(expected.length), 0, expected.length, 0);
12
12
 
13
- assert(bytesRead == expected.length);
13
+ assert.equal(bytesRead, expected.length);
14
14
  assert(buffer.toString() == expected);
15
15
  });
16
16
 
@@ -19,7 +19,7 @@ suite('read', () => {
19
19
  const buffer = Buffer.alloc(expected.length);
20
20
  const bytesRead = fs.readSync(fd, buffer, 0, expected.length, 0);
21
21
 
22
- assert(bytesRead == expected.length);
22
+ assert.equal(bytesRead, expected.length);
23
23
  assert(buffer.toString() == expected);
24
24
  });
25
25
  });
@@ -44,7 +44,7 @@ suite('read buffer', () => {
44
44
  const handle = await fs.promises.open(filepath, 'r');
45
45
  const { bytesRead } = await handle.read(bufferAsync, 0, expected.length, 0);
46
46
 
47
- assert(bytesRead === expected.length);
47
+ assert.strictEqual(bytesRead, expected.length);
48
48
  assert(bufferAsync.toString() === expected);
49
49
  });
50
50
 
@@ -53,7 +53,7 @@ suite('read buffer', () => {
53
53
  const bytesRead = fs.readSync(fd, bufferSync, 0, expected.length, 0);
54
54
 
55
55
  assert(bufferSync.toString() === expected);
56
- assert(bytesRead === expected.length);
56
+ assert.strictEqual(bytesRead, expected.length);
57
57
  });
58
58
 
59
59
  test('read file synchronously to non-zero offset', () => {
@@ -62,6 +62,6 @@ suite('read buffer', () => {
62
62
  const bytesRead = fs.readSync(fd, buffer, 10, expected.length, 0);
63
63
 
64
64
  assert(buffer.subarray(10, buffer.length).toString() === expected);
65
- assert(bytesRead === expected.length);
65
+ assert.strictEqual(bytesRead, expected.length);
66
66
  });
67
67
  });
@@ -65,9 +65,9 @@ suite('fs file reading', () => {
65
65
  const content = fs.readFileSync('elipses.txt', 'utf8');
66
66
 
67
67
  for (let i = 0; i < content.length; i++) {
68
- assert(content[i] === '…');
68
+ assert.strictEqual(content[i], '…');
69
69
  }
70
70
 
71
- assert(content.length === 10000);
71
+ assert.strictEqual(content.length, 10000);
72
72
  });
73
73
  });
@@ -1,6 +1,6 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
- import { ErrnoError } from '../../src/error.js';
3
+ import { ErrnoError } from '../../dist/error.js';
4
4
  import { fs } from '../common.js';
5
5
 
6
6
  suite('Rename', () => {
@@ -21,10 +21,10 @@ suite('Rename', () => {
21
21
  */
22
22
  async function check_directory(dir: string) {
23
23
  const contents = await fs.promises.readdir(dir);
24
- assert(contents.length === 2);
24
+ assert.strictEqual(contents.length, 2);
25
25
 
26
26
  const subContents = await fs.promises.readdir(dir + '/_rename_me');
27
- assert(subContents.length === 1);
27
+ assert.strictEqual(subContents.length, 1);
28
28
 
29
29
  assert(await fs.promises.exists(dir + '/file.dat'));
30
30
  assert(await fs.promises.exists(dir + '/_rename_me/lol.txt'));
@@ -88,7 +88,7 @@ suite('Rename', () => {
88
88
  if (e == null) {
89
89
  throw new Error("Failed invariant: Cannot rename a directory over a file.");
90
90
  } else {
91
- assert(e.code === 'ENOTDIR');
91
+ assert.strictEqual(e.code, 'ENOTDIR');
92
92
  }
93
93
  });*/
94
94
  });
@@ -101,7 +101,7 @@ suite('Rename', () => {
101
101
 
102
102
  await fs.promises.rename(renDir1, renDir2).catch((error: ErrnoError) => {
103
103
  assert(error instanceof ErrnoError);
104
- assert(error.code === 'EBUSY');
104
+ assert.strictEqual(error.code, 'EBUSY');
105
105
  });
106
106
  });
107
107
  });
@@ -1,6 +1,6 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
- import { Stats } from '../../src/stats.js';
3
+ import { Stats } from '../../dist/stats.js';
4
4
  import { fs } from '../common.js';
5
5
 
6
6
  suite('Stats', () => {
@@ -18,7 +18,7 @@ suite('ReadStream', () => {
18
18
  data += chunk;
19
19
  });
20
20
  readStream.on('end', () => {
21
- assert(data == testData);
21
+ assert.equal(data, testData);
22
22
  done();
23
23
  });
24
24
  readStream.on('error', err => {
@@ -33,7 +33,7 @@ suite('ReadStream', () => {
33
33
  closed = true;
34
34
  });
35
35
  readStream.close(err => {
36
- assert(err === undefined);
36
+ assert.strictEqual(err, undefined);
37
37
  assert(closed);
38
38
  done();
39
39
  });
@@ -41,27 +41,27 @@ suite('ReadStream', () => {
41
41
 
42
42
  test('ReadStream declared properties', () => {
43
43
  const readStream = new fs.ReadStream();
44
- assert(readStream.bytesRead === undefined);
45
- assert(readStream.path === undefined);
46
- assert(readStream.pending === undefined);
44
+ assert.strictEqual(readStream.bytesRead, undefined);
45
+ assert.strictEqual(readStream.path, undefined);
46
+ assert.strictEqual(readStream.pending, undefined);
47
47
 
48
48
  // Assign values
49
49
  readStream.bytesRead = 10;
50
50
  readStream.path = testFilePath;
51
51
  readStream.pending = false;
52
52
 
53
- assert(readStream.bytesRead === 10);
54
- assert(readStream.path === testFilePath);
53
+ assert.strictEqual(readStream.bytesRead, 10);
54
+ assert.strictEqual(readStream.path, testFilePath);
55
55
  assert(!readStream.pending);
56
56
  });
57
57
 
58
58
  test('ReadStream close method can be called multiple times', (_, done) => {
59
59
  const readStream = new fs.ReadStream();
60
60
  readStream.close(err => {
61
- assert(err === undefined);
61
+ assert.strictEqual(err, undefined);
62
62
  // Call close again
63
63
  readStream.close(err2 => {
64
- assert(err2 === undefined);
64
+ assert.strictEqual(err2, undefined);
65
65
  done();
66
66
  });
67
67
  });
@@ -94,7 +94,7 @@ suite('WriteStream', () => {
94
94
  closed = true;
95
95
  });
96
96
  writeStream.close(err => {
97
- assert(err === undefined);
97
+ assert.strictEqual(err, undefined);
98
98
  assert(closed);
99
99
  done();
100
100
  });
@@ -102,27 +102,27 @@ suite('WriteStream', () => {
102
102
 
103
103
  test('WriteStream declared properties', () => {
104
104
  const writeStream = new fs.WriteStream();
105
- assert(writeStream.bytesWritten === undefined);
106
- assert(writeStream.path === undefined);
107
- assert(writeStream.pending === undefined);
105
+ assert.strictEqual(writeStream.bytesWritten, undefined);
106
+ assert.strictEqual(writeStream.path, undefined);
107
+ assert.strictEqual(writeStream.pending, undefined);
108
108
 
109
109
  // Assign values
110
110
  writeStream.bytesWritten = 20;
111
111
  writeStream.path = testFilePathWrite;
112
112
  writeStream.pending = true;
113
113
 
114
- assert(writeStream.bytesWritten === 20);
115
- assert(writeStream.path === testFilePathWrite);
114
+ assert.strictEqual(writeStream.bytesWritten, 20);
115
+ assert.strictEqual(writeStream.path, testFilePathWrite);
116
116
  assert(writeStream.pending);
117
117
  });
118
118
 
119
119
  test('WriteStream close method can be called multiple times', (_, done) => {
120
120
  const writeStream = new fs.WriteStream();
121
121
  writeStream.close(err => {
122
- assert(err === undefined);
122
+ assert.strictEqual(err, undefined);
123
123
  // Call close again
124
124
  writeStream.close(err2 => {
125
- assert(err2 === undefined);
125
+ assert.strictEqual(err2, undefined);
126
126
  done();
127
127
  });
128
128
  });
@@ -139,7 +139,7 @@ suite('FileHandle', () => {
139
139
  data += chunk;
140
140
  });
141
141
  readStream.on('end', () => {
142
- assert(data == testData);
142
+ assert.equal(data, testData);
143
143
  resolve();
144
144
  });
145
145
  readStream.on('error', reject);
@@ -159,7 +159,7 @@ suite('FileHandle', () => {
159
159
  writeStream.on('error', reject);
160
160
  });
161
161
  const data = await fs.promises.readFile(testFilePathWrite, 'utf8');
162
- assert(data == testData);
162
+ assert.equal(data, testData);
163
163
  await fileHandle.close();
164
164
  });
165
165
 
@@ -1,8 +1,8 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
3
  import { wait } from 'utilium';
4
- import { ErrnoError } from '../../src/error.js';
5
- import { _toUnixTimestamp } from '../../src/utils.js';
4
+ import { ErrnoError } from '../../dist/error.js';
5
+ import { _toUnixTimestamp } from '../../dist/utils.js';
6
6
  import { fs } from '../common.js';
7
7
 
8
8
  suite('times', () => {
@@ -21,7 +21,7 @@ suite('times', () => {
21
21
 
22
22
  await fs.promises.utimes('foobarbaz', atime, mtime).catch((error: ErrnoError) => {
23
23
  assert(error instanceof ErrnoError);
24
- assert(error.code === 'ENOENT');
24
+ assert.strictEqual(error.code, 'ENOENT');
25
25
  });
26
26
 
27
27
  // don't close this fd
@@ -40,21 +40,21 @@ suite('times', () => {
40
40
  expect_assert(handle.fd, atime, mtime);
41
41
  } catch (error: any) {
42
42
  assert(error instanceof ErrnoError);
43
- assert(error.code === 'ENOSYS');
43
+ assert.strictEqual(error.code, 'ENOSYS');
44
44
  }
45
45
 
46
46
  try {
47
47
  fs.utimesSync('foobarbaz', atime, mtime);
48
48
  } catch (error: any) {
49
49
  assert(error instanceof ErrnoError);
50
- assert(error.code === 'ENOENT');
50
+ assert.strictEqual(error.code, 'ENOENT');
51
51
  }
52
52
 
53
53
  try {
54
54
  fs.futimesSync(-1, atime, mtime);
55
55
  } catch (error: any) {
56
56
  assert(error instanceof ErrnoError);
57
- assert(error.code == 'EBADF');
57
+ assert.equal(error.code, 'EBADF');
58
58
  }
59
59
  }
60
60
 
@@ -1,7 +1,7 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
- import type { FileHandle } from '../../src/emulation/promises.js';
4
3
  import { fs } from '../common.js';
4
+ import type { FileHandle } from '../../dist/emulation/promises.js';
5
5
 
6
6
  const path: string = 'truncate-file.txt',
7
7
  size = 1024 * 16,