@zenfs/core 2.0.0 → 2.1.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.
Files changed (88) hide show
  1. package/dist/backends/backend.js +6 -5
  2. package/dist/backends/cow.d.ts +2 -2
  3. package/dist/backends/cow.js +39 -58
  4. package/dist/backends/fetch.js +27 -29
  5. package/dist/backends/passthrough.d.ts +2 -3
  6. package/dist/backends/passthrough.js +84 -199
  7. package/dist/backends/port.d.ts +16 -3
  8. package/dist/backends/port.js +61 -30
  9. package/dist/backends/single_buffer.d.ts +52 -46
  10. package/dist/backends/single_buffer.js +462 -219
  11. package/dist/backends/store/fs.d.ts +16 -10
  12. package/dist/backends/store/fs.js +227 -242
  13. package/dist/backends/store/store.d.ts +3 -3
  14. package/dist/backends/store/store.js +11 -10
  15. package/dist/config.d.ts +2 -2
  16. package/dist/config.js +10 -11
  17. package/dist/internal/devices.d.ts +2 -2
  18. package/dist/internal/devices.js +39 -49
  19. package/dist/internal/error.d.ts +9 -204
  20. package/dist/internal/error.js +19 -288
  21. package/dist/internal/file_index.d.ts +1 -1
  22. package/dist/internal/file_index.js +9 -9
  23. package/dist/internal/filesystem.d.ts +23 -8
  24. package/dist/internal/index.d.ts +1 -1
  25. package/dist/internal/index.js +1 -1
  26. package/dist/internal/index_fs.d.ts +2 -2
  27. package/dist/internal/index_fs.js +19 -19
  28. package/dist/internal/inode.d.ts +81 -103
  29. package/dist/internal/inode.js +336 -195
  30. package/dist/mixins/async.js +32 -28
  31. package/dist/mixins/mutexed.d.ts +4 -4
  32. package/dist/mixins/mutexed.js +39 -39
  33. package/dist/mixins/readonly.d.ts +2 -2
  34. package/dist/mixins/readonly.js +20 -20
  35. package/dist/mixins/sync.js +2 -2
  36. package/dist/polyfills.js +1 -1
  37. package/dist/readline.js +1 -1
  38. package/dist/utils.d.ts +8 -5
  39. package/dist/utils.js +14 -17
  40. package/dist/vfs/acl.d.ts +8 -8
  41. package/dist/vfs/acl.js +66 -47
  42. package/dist/vfs/async.d.ts +2 -2
  43. package/dist/vfs/async.js +6 -8
  44. package/dist/vfs/dir.d.ts +1 -1
  45. package/dist/vfs/dir.js +3 -4
  46. package/dist/vfs/file.js +33 -24
  47. package/dist/vfs/flags.js +3 -3
  48. package/dist/vfs/ioctl.d.ts +8 -7
  49. package/dist/vfs/ioctl.js +132 -27
  50. package/dist/vfs/promises.d.ts +3 -3
  51. package/dist/vfs/promises.js +200 -235
  52. package/dist/vfs/shared.d.ts +1 -12
  53. package/dist/vfs/shared.js +7 -35
  54. package/dist/vfs/streams.js +9 -9
  55. package/dist/vfs/sync.d.ts +1 -2
  56. package/dist/vfs/sync.js +158 -170
  57. package/dist/vfs/watchers.js +8 -8
  58. package/dist/vfs/xattr.js +89 -106
  59. package/package.json +5 -3
  60. package/scripts/test.js +2 -2
  61. package/tests/assignment.ts +1 -1
  62. package/tests/backend/port.test.ts +4 -4
  63. package/tests/backend/single-buffer.test.ts +39 -10
  64. package/tests/backend/single-buffer.worker.js +30 -0
  65. package/tests/common/context.test.ts +2 -2
  66. package/tests/common/mutex.test.ts +9 -9
  67. package/tests/fetch/fetch.ts +1 -1
  68. package/tests/fetch/run.sh +1 -1
  69. package/tests/fs/append.test.ts +4 -4
  70. package/tests/fs/directory.test.ts +25 -25
  71. package/tests/fs/errors.test.ts +15 -19
  72. package/tests/fs/links.test.ts +3 -2
  73. package/tests/fs/open.test.ts +4 -21
  74. package/tests/fs/permissions.test.ts +8 -13
  75. package/tests/fs/read.test.ts +10 -9
  76. package/tests/fs/readFile.test.ts +8 -24
  77. package/tests/fs/rename.test.ts +4 -9
  78. package/tests/fs/stat.test.ts +2 -2
  79. package/tests/fs/times.test.ts +6 -6
  80. package/tests/fs/truncate.test.ts +8 -36
  81. package/tests/fs/watch.test.ts +10 -10
  82. package/tests/fs/write.test.ts +77 -13
  83. package/tests/fs/xattr.test.ts +7 -7
  84. package/tests/logs.js +2 -2
  85. package/tests/setup/port.ts +6 -0
  86. package/dist/internal/log.d.ts +0 -139
  87. package/dist/internal/log.js +0 -219
  88. package/tests/fs/writeFile.test.ts +0 -70
@@ -51,7 +51,7 @@ export interface Store {
51
51
  /**
52
52
  * @internal @hidden
53
53
  */
54
- _fs?: StoreFS;
54
+ fs?: StoreFS;
55
55
  }
56
56
  /**
57
57
  * A transaction for a store.
@@ -169,8 +169,8 @@ export declare class WrappedTransaction<T extends Store = Store> {
169
169
  keys(): Promise<Iterable<number>>;
170
170
  get(id: number, offset?: number, end?: number): Promise<Uint8Array | undefined>;
171
171
  getSync(id: number, offset?: number, end?: number): Uint8Array | undefined;
172
- set(id: number, data: Uint8Array, offset?: number): Promise<void>;
173
- setSync(id: number, data: Uint8Array, offset?: number): void;
172
+ set(id: number, view: Uint8Array | ArrayBufferView, offset?: number): Promise<void>;
173
+ setSync(id: number, view: Uint8Array | ArrayBufferView, offset?: number): void;
174
174
  remove(id: number): Promise<void>;
175
175
  removeSync(id: number): void;
176
176
  commit(): Promise<void>;
@@ -1,6 +1,6 @@
1
+ import { withErrno } from 'kerium';
2
+ import { warn } from 'kerium/log';
1
3
  import { Resource } from 'utilium/cache.js';
2
- import { ErrnoError } from '../../internal/error.js';
3
- import { err, warn } from '../../internal/log.js';
4
4
  import '../../polyfills.js';
5
5
  /**
6
6
  * A transaction for a store.
@@ -62,7 +62,6 @@ export class AsyncTransaction extends Transaction {
62
62
  return resource;
63
63
  }
64
64
  getSync(id, offset, end) {
65
- var _a;
66
65
  const resource = this._cached(id);
67
66
  if (!resource)
68
67
  return;
@@ -72,7 +71,7 @@ export class AsyncTransaction extends Transaction {
72
71
  this.async(this.get(id, start, end));
73
72
  }
74
73
  if (missing.length)
75
- throw err(ErrnoError.With('EAGAIN', (_a = this.store._fs) === null || _a === void 0 ? void 0 : _a._path(id)));
74
+ throw withErrno('EAGAIN');
76
75
  const region = resource.regionAt(offset);
77
76
  if (!region) {
78
77
  warn('Missing cache region for ' + id);
@@ -130,13 +129,15 @@ export class WrappedTransaction {
130
129
  this.stash(id);
131
130
  return data;
132
131
  }
133
- async set(id, data, offset = 0) {
134
- await this.markModified(id, offset, data.byteLength);
135
- await this.raw.set(id, data, offset);
132
+ async set(id, view, offset = 0) {
133
+ await this.markModified(id, offset, view.byteLength);
134
+ const buffer = view instanceof Uint8Array ? view : new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
135
+ await this.raw.set(id, buffer, offset);
136
136
  }
137
- setSync(id, data, offset = 0) {
138
- this.markModifiedSync(id, offset, data.byteLength);
139
- this.raw.setSync(id, data, offset);
137
+ setSync(id, view, offset = 0) {
138
+ this.markModifiedSync(id, offset, view.byteLength);
139
+ const buffer = view instanceof Uint8Array ? view : new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
140
+ this.raw.setSync(id, buffer, offset);
140
141
  }
141
142
  async remove(id) {
142
143
  await this.markModified(id, 0, undefined);
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Backend, BackendConfiguration, FilesystemOf, SharedConfig } from './backends/backend.js';
2
2
  import type { Device, DeviceDriver } from './internal/devices.js';
3
- import type { LogConfiguration } from './internal/log.js';
3
+ import { log } from 'kerium';
4
4
  /**
5
5
  * Configuration for a specific mount point
6
6
  * @category Backends and Configuration
@@ -64,7 +64,7 @@ export interface Configuration<T extends ConfigMounts> extends SharedConfig {
64
64
  /**
65
65
  * Configurations options for the log.
66
66
  */
67
- log: LogConfiguration;
67
+ log: log.Configuration;
68
68
  }
69
69
  /**
70
70
  * Configures ZenFS with single mount point /
package/dist/config.js CHANGED
@@ -1,10 +1,9 @@
1
+ import { log, withErrno } from 'kerium';
1
2
  import { checkOptions, isBackend, isBackendConfig } from './backends/backend.js';
2
3
  import { defaultContext } from './internal/contexts.js';
3
4
  import { createCredentials } from './internal/credentials.js';
4
5
  import { DeviceFS } from './internal/devices.js';
5
- import { Errno, ErrnoError } from './internal/error.js';
6
6
  import { FileSystem } from './internal/filesystem.js';
7
- import { configure as configureLog, crit, err, info } from './internal/log.js';
8
7
  import { _setAccessChecks } from './vfs/config.js';
9
8
  import * as fs from './vfs/index.js';
10
9
  import { mounts } from './vfs/shared.js';
@@ -18,10 +17,10 @@ function isMountConfig(arg) {
18
17
  */
19
18
  export async function resolveMountConfig(configuration, _depth = 0) {
20
19
  if (typeof configuration !== 'object' || configuration == null) {
21
- throw err(new ErrnoError(Errno.EINVAL, 'Invalid options on mount configuration'));
20
+ throw log.err(withErrno('EINVAL', 'Invalid options on mount configuration'));
22
21
  }
23
22
  if (!isMountConfig(configuration)) {
24
- throw err(new ErrnoError(Errno.EINVAL, 'Invalid mount configuration'));
23
+ throw log.err(withErrno('EINVAL', 'Invalid mount configuration'));
25
24
  }
26
25
  if (configuration instanceof FileSystem) {
27
26
  await configuration.ready();
@@ -35,20 +34,20 @@ export async function resolveMountConfig(configuration, _depth = 0) {
35
34
  continue;
36
35
  if (!isMountConfig(value))
37
36
  continue;
38
- info('Resolving nested mount configuration: ' + key);
37
+ log.info('Resolving nested mount configuration: ' + key);
39
38
  if (_depth > 10) {
40
- throw err(new ErrnoError(Errno.EINVAL, 'Invalid configuration, too deep and possibly infinite'));
39
+ throw log.err(withErrno('EINVAL', 'Invalid configuration, too deep and possibly infinite'));
41
40
  }
42
41
  configuration[key] = await resolveMountConfig(value, ++_depth);
43
42
  }
44
43
  const { backend } = configuration;
45
44
  if (typeof backend.isAvailable == 'function' && !(await backend.isAvailable(configuration))) {
46
- throw err(new ErrnoError(Errno.EPERM, 'Backend not available: ' + backend.name));
45
+ throw log.err(withErrno('EPERM', 'Backend not available: ' + backend.name));
47
46
  }
48
47
  checkOptions(backend, configuration);
49
48
  const mount = (await backend.create(configuration));
50
49
  if (configuration.disableAsyncCache)
51
- mount.attributes.set('no_async');
50
+ mount.attributes.set('no_async_preload');
52
51
  await mount.ready();
53
52
  return mount;
54
53
  }
@@ -80,7 +79,7 @@ async function mount(path, mount) {
80
79
  await fs.promises.mkdir(path, { recursive: true });
81
80
  }
82
81
  else if (!stats.isDirectory()) {
83
- throw ErrnoError.With('ENOTDIR', path, 'configure');
82
+ throw withErrno('ENOTDIR', 'Missing directory at mount point: ' + path);
84
83
  }
85
84
  fs.mount(path, mount);
86
85
  }
@@ -90,7 +89,7 @@ async function mount(path, mount) {
90
89
  export function addDevice(driver, options) {
91
90
  const devfs = mounts.get('/dev');
92
91
  if (!(devfs instanceof DeviceFS))
93
- throw crit(new ErrnoError(Errno.ENOTSUP, '/dev does not exist or is not a device file system'));
92
+ throw log.crit(withErrno('ENOTSUP', '/dev does not exist or is not a device file system'));
94
93
  return devfs._createDevice(driver, options);
95
94
  }
96
95
  /**
@@ -105,7 +104,7 @@ export async function configure(configuration) {
105
104
  Object.assign(defaultContext.credentials, createCredentials({ uid, gid }));
106
105
  _setAccessChecks(!configuration.disableAccessChecks);
107
106
  if (configuration.log)
108
- configureLog(configuration.log);
107
+ log.configure(configuration.log);
109
108
  if (configuration.mounts) {
110
109
  // sort to make sure any root replacement is done first
111
110
  for (const [_point, mountConfig] of Object.entries(configuration.mounts).sort(([a], [b]) => (a.length > b.length ? 1 : -1))) {
@@ -119,8 +119,8 @@ export declare class DeviceFS extends StoreFS<InMemoryStore> {
119
119
  readdirSync(path: string): string[];
120
120
  link(target: string, link: string): Promise<void>;
121
121
  linkSync(target: string, link: string): void;
122
- sync(path: string): Promise<void>;
123
- syncSync(path: string): void;
122
+ sync(): Promise<void>;
123
+ syncSync(): void;
124
124
  read(path: string, buffer: Uint8Array, offset: number, end: number): Promise<void>;
125
125
  readSync(path: string, buffer: Uint8Array, offset: number, end: number): void;
126
126
  write(path: string, data: Uint8Array, offset: number): Promise<void>;
@@ -1,14 +1,14 @@
1
1
  /*
2
2
  This is a great resource: https://www.kernel.org/doc/html/latest/admin-guide/devices.html
3
3
  */
4
+ import { withErrno } from 'kerium';
5
+ import { debug, err, info } from 'kerium/log';
4
6
  import { decodeUTF8, omit } from 'utilium';
5
7
  import { InMemoryStore } from '../backends/memory.js';
6
8
  import { StoreFS } from '../backends/store/fs.js';
7
9
  import { basename, dirname } from '../path.js';
8
10
  import { S_IFCHR } from '../vfs/constants.js';
9
- import { Errno, ErrnoError } from './error.js';
10
11
  import { Inode } from './inode.js';
11
- import { debug, err, info } from './log.js';
12
12
  /**
13
13
  * A temporary file system that manages and interfaces with devices
14
14
  * @category Internals
@@ -16,7 +16,7 @@ import { debug, err, info } from './log.js';
16
16
  export class DeviceFS extends StoreFS {
17
17
  devicesWithDriver(driver, forceIdentity) {
18
18
  if (forceIdentity && typeof driver == 'string') {
19
- throw err(new ErrnoError(Errno.EINVAL, 'Can not fetch devices using only a driver name'), { fs: this });
19
+ throw err(withErrno('EINVAL', 'Can not fetch devices using only a driver name'));
20
20
  }
21
21
  const devs = [];
22
22
  for (const device of this.devices.values()) {
@@ -51,7 +51,7 @@ export class DeviceFS extends StoreFS {
51
51
  };
52
52
  const path = '/' + (dev.name || driver.name) + (driver.singleton ? '' : this.devicesWithDriver(driver).length);
53
53
  if (this.existsSync(path))
54
- throw ErrnoError.With('EEXIST', path, 'mknod');
54
+ throw withErrno('EEXIST');
55
55
  this.devices.set(path, dev);
56
56
  info('Initialized device: ' + this._mountPoint + path);
57
57
  return dev;
@@ -74,21 +74,17 @@ export class DeviceFS extends StoreFS {
74
74
  this.devices = new Map();
75
75
  }
76
76
  async rename(oldPath, newPath) {
77
- if (this.devices.has(oldPath)) {
78
- throw ErrnoError.With('EPERM', oldPath, 'rename');
79
- }
80
- if (this.devices.has(newPath)) {
81
- throw ErrnoError.With('EEXIST', newPath, 'rename');
82
- }
77
+ if (this.devices.has(oldPath))
78
+ throw withErrno('EPERM');
79
+ if (this.devices.has(newPath))
80
+ throw withErrno('EEXIST');
83
81
  return super.rename(oldPath, newPath);
84
82
  }
85
83
  renameSync(oldPath, newPath) {
86
- if (this.devices.has(oldPath)) {
87
- throw ErrnoError.With('EPERM', oldPath, 'rename');
88
- }
89
- if (this.devices.has(newPath)) {
90
- throw ErrnoError.With('EEXIST', newPath, 'rename');
91
- }
84
+ if (this.devices.has(oldPath))
85
+ throw withErrno('EPERM');
86
+ if (this.devices.has(newPath))
87
+ throw withErrno('EEXIST');
92
88
  return super.renameSync(oldPath, newPath);
93
89
  }
94
90
  async stat(path) {
@@ -119,24 +115,22 @@ export class DeviceFS extends StoreFS {
119
115
  }
120
116
  async createFile(path, options) {
121
117
  if (this.devices.has(path))
122
- throw ErrnoError.With('EEXIST', path, 'createFile');
118
+ throw withErrno('EEXIST');
123
119
  return super.createFile(path, options);
124
120
  }
125
121
  createFileSync(path, options) {
126
122
  if (this.devices.has(path))
127
- throw ErrnoError.With('EEXIST', path, 'createFile');
123
+ throw withErrno('EEXIST');
128
124
  return super.createFileSync(path, options);
129
125
  }
130
126
  async unlink(path) {
131
- if (this.devices.has(path)) {
132
- throw ErrnoError.With('EPERM', path, 'unlink');
133
- }
127
+ if (this.devices.has(path))
128
+ throw withErrno('EPERM');
134
129
  return super.unlink(path);
135
130
  }
136
131
  unlinkSync(path) {
137
- if (this.devices.has(path)) {
138
- throw ErrnoError.With('EPERM', path, 'unlink');
139
- }
132
+ if (this.devices.has(path))
133
+ throw withErrno('EPERM');
140
134
  return super.unlinkSync(path);
141
135
  }
142
136
  async rmdir(path) {
@@ -147,12 +141,12 @@ export class DeviceFS extends StoreFS {
147
141
  }
148
142
  async mkdir(path, options) {
149
143
  if (this.devices.has(path))
150
- throw ErrnoError.With('EEXIST', path, 'mkdir');
144
+ throw withErrno('EEXIST');
151
145
  return super.mkdir(path, options);
152
146
  }
153
147
  mkdirSync(path, options) {
154
148
  if (this.devices.has(path))
155
- throw ErrnoError.With('EEXIST', path, 'mkdir');
149
+ throw withErrno('EEXIST');
156
150
  return super.mkdirSync(path, options);
157
151
  }
158
152
  async readdir(path) {
@@ -174,36 +168,32 @@ export class DeviceFS extends StoreFS {
174
168
  return entries;
175
169
  }
176
170
  async link(target, link) {
177
- if (this.devices.has(target)) {
178
- throw ErrnoError.With('EPERM', target, 'rmdir');
179
- }
180
- if (this.devices.has(link)) {
181
- throw ErrnoError.With('EEXIST', link, 'link');
182
- }
171
+ if (this.devices.has(target))
172
+ throw withErrno('EPERM');
173
+ if (this.devices.has(link))
174
+ throw withErrno('EEXIST');
183
175
  return super.link(target, link);
184
176
  }
185
177
  linkSync(target, link) {
186
- if (this.devices.has(target)) {
187
- throw ErrnoError.With('EPERM', target, 'rmdir');
188
- }
189
- if (this.devices.has(link)) {
190
- throw ErrnoError.With('EEXIST', link, 'link');
191
- }
178
+ if (this.devices.has(target))
179
+ throw withErrno('EPERM');
180
+ if (this.devices.has(link))
181
+ throw withErrno('EEXIST');
192
182
  return super.linkSync(target, link);
193
183
  }
194
- async sync(path) {
184
+ async sync() {
195
185
  var _a, _b;
196
- const device = this.devices.get(path);
197
- if (device)
198
- return (_b = (_a = device.driver).sync) === null || _b === void 0 ? void 0 : _b.call(_a, device);
199
- return super.sync(path);
186
+ for (const device of this.devices.values()) {
187
+ (_b = (_a = device.driver).sync) === null || _b === void 0 ? void 0 : _b.call(_a, device);
188
+ }
189
+ return super.sync();
200
190
  }
201
- syncSync(path) {
191
+ syncSync() {
202
192
  var _a, _b;
203
- const device = this.devices.get(path);
204
- if (device)
205
- return (_b = (_a = device.driver).sync) === null || _b === void 0 ? void 0 : _b.call(_a, device);
206
- return super.syncSync(path);
193
+ for (const device of this.devices.values()) {
194
+ (_b = (_a = device.driver).sync) === null || _b === void 0 ? void 0 : _b.call(_a, device);
195
+ }
196
+ return super.syncSync();
207
197
  }
208
198
  async read(path, buffer, offset, end) {
209
199
  const device = this.devices.get(path);
@@ -298,7 +288,7 @@ export const fullDevice = {
298
288
  buffer.fill(0, offset, end);
299
289
  },
300
290
  write() {
301
- throw ErrnoError.With('ENOSPC', undefined, 'write');
291
+ throw withErrno('ENOSPC');
302
292
  },
303
293
  };
304
294
  /**
@@ -1,213 +1,18 @@
1
+ import { Exception, type ExceptionJSON } from 'kerium';
1
2
  /**
2
- * Standard libc error codes. More will be added to this enum and error strings as they are
3
- * needed.
3
+ * @deprecated Use {@link ExceptionJSON} instead
4
4
  * @category Internals
5
- * @see https://en.wikipedia.org/wiki/Errno.h
6
5
  */
7
- export declare enum Errno {
8
- /** Operation not permitted */
9
- EPERM = 1,
10
- /** No such file or directory */
11
- ENOENT = 2,
12
- /** Interrupted system call */
13
- EINTR = 4,
14
- /** Input/output error */
15
- EIO = 5,
16
- /** No such device or address */
17
- ENXIO = 6,
18
- /** Bad file descriptor */
19
- EBADF = 9,
20
- /** Resource temporarily unavailable */
21
- EAGAIN = 11,
22
- /** Cannot allocate memory */
23
- ENOMEM = 12,
24
- /** Permission denied */
25
- EACCES = 13,
26
- /** Bad address */
27
- EFAULT = 14,
28
- /** Block device required */
29
- ENOTBLK = 15,
30
- /** Resource busy or locked */
31
- EBUSY = 16,
32
- /** File exists */
33
- EEXIST = 17,
34
- /** Invalid cross-device link */
35
- EXDEV = 18,
36
- /** No such device */
37
- ENODEV = 19,
38
- /** File is not a directory */
39
- ENOTDIR = 20,
40
- /** File is a directory */
41
- EISDIR = 21,
42
- /** Invalid argument */
43
- EINVAL = 22,
44
- /** Too many open files in system */
45
- ENFILE = 23,
46
- /** Too many open files */
47
- EMFILE = 24,
48
- /** Text file busy */
49
- ETXTBSY = 26,
50
- /** File is too big */
51
- EFBIG = 27,
52
- /** No space left on disk */
53
- ENOSPC = 28,
54
- /** Illegal seek */
55
- ESPIPE = 29,
56
- /** Cannot modify a read-only file system */
57
- EROFS = 30,
58
- /** Too many links */
59
- EMLINK = 31,
60
- /** Broken pipe */
61
- EPIPE = 32,
62
- /** Numerical argument out of domain */
63
- EDOM = 33,
64
- /** Numerical result out of range */
65
- ERANGE = 34,
66
- /** Resource deadlock would occur */
67
- EDEADLK = 35,
68
- /** File name too long */
69
- ENAMETOOLONG = 36,
70
- /** No locks available */
71
- ENOLCK = 37,
72
- /** Function not implemented */
73
- ENOSYS = 38,
74
- /** Directory is not empty */
75
- ENOTEMPTY = 39,
76
- /** Too many levels of symbolic links */
77
- ELOOP = 40,
78
- /** No message of desired type */
79
- ENOMSG = 42,
80
- /** Invalid exchange */
81
- EBADE = 52,
82
- /** Invalid request descriptor */
83
- EBADR = 53,
84
- /** Exchange full */
85
- EXFULL = 54,
86
- /** No anode */
87
- ENOANO = 55,
88
- /** Invalid request code */
89
- EBADRQC = 56,
90
- /** Device not a stream */
91
- ENOSTR = 60,
92
- /** No data available */
93
- ENODATA = 61,
94
- /** Timer expired */
95
- ETIME = 62,
96
- /** Out of streams resources */
97
- ENOSR = 63,
98
- /** Machine is not on the network */
99
- ENONET = 64,
100
- /** Object is remote */
101
- EREMOTE = 66,
102
- /** Link has been severed */
103
- ENOLINK = 67,
104
- /** Communication error on send */
105
- ECOMM = 70,
106
- /** Protocol error */
107
- EPROTO = 71,
108
- /** Bad message */
109
- EBADMSG = 74,
110
- /** Value too large for defined data type */
111
- EOVERFLOW = 75,
112
- /** File descriptor in bad state */
113
- EBADFD = 77,
114
- /** Streams pipe error */
115
- ESTRPIPE = 86,
116
- /** Socket operation on non-socket */
117
- ENOTSOCK = 88,
118
- /** Destination address required */
119
- EDESTADDRREQ = 89,
120
- /** Message too long */
121
- EMSGSIZE = 90,
122
- /** Protocol wrong type for socket */
123
- EPROTOTYPE = 91,
124
- /** Protocol not available */
125
- ENOPROTOOPT = 92,
126
- /** Protocol not supported */
127
- EPROTONOSUPPORT = 93,
128
- /** Socket type not supported */
129
- ESOCKTNOSUPPORT = 94,
130
- /** Operation is not supported */
131
- ENOTSUP = 95,
132
- /** Network is down */
133
- ENETDOWN = 100,
134
- /** Network is unreachable */
135
- ENETUNREACH = 101,
136
- /** Network dropped connection on reset */
137
- ENETRESET = 102,
138
- /** Connection timed out */
139
- ETIMEDOUT = 110,
140
- /** Connection refused */
141
- ECONNREFUSED = 111,
142
- /** Host is down */
143
- EHOSTDOWN = 112,
144
- /** No route to host */
145
- EHOSTUNREACH = 113,
146
- /** Operation already in progress */
147
- EALREADY = 114,
148
- /** Operation now in progress */
149
- EINPROGRESS = 115,
150
- /** Stale file handle */
151
- ESTALE = 116,
152
- /** Remote I/O error */
153
- EREMOTEIO = 121,
154
- /** Disk quota exceeded */
155
- EDQUOT = 122
156
- }
6
+ export type ErrnoErrorJSON = ExceptionJSON;
157
7
  /**
158
- * Strings associated with each error code.
8
+ * @deprecated Use {@link Exception} instead
159
9
  * @category Internals
160
- * @internal
161
10
  */
162
- export declare const errorMessages: {
163
- [K in Errno]: string;
164
- };
11
+ export declare const ErrnoError: typeof Exception;
165
12
  /**
13
+ * @deprecated Use {@link Exception} instead
166
14
  * @category Internals
167
15
  */
168
- export interface ErrnoErrorJSON {
169
- errno: Errno;
170
- message: string;
171
- path?: string;
172
- code: keyof typeof Errno;
173
- stack: string;
174
- syscall: string;
175
- }
176
- /**
177
- * An error with additional information about what happened
178
- * @category Internals
179
- */
180
- export declare class ErrnoError extends Error implements NodeJS.ErrnoException {
181
- /**
182
- * The kind of error
183
- */
184
- errno: Errno;
185
- /**
186
- * A descriptive error message
187
- */
188
- message: string;
189
- path?: string | undefined;
190
- syscall: string;
191
- static fromJSON(json: ErrnoErrorJSON): ErrnoError;
192
- static With(code: keyof typeof Errno, path?: string, syscall?: string): ErrnoError;
193
- code: keyof typeof Errno;
194
- stack: string;
195
- constructor(
196
- /**
197
- * The kind of error
198
- */
199
- errno: Errno,
200
- /**
201
- * A descriptive error message
202
- */
203
- message?: string, path?: string | undefined, syscall?: string);
204
- /**
205
- * @returns A friendly error message.
206
- */
207
- toString(): string;
208
- toJSON(): ErrnoErrorJSON;
209
- /**
210
- * The size of the API error in buffer-form in bytes.
211
- */
212
- bufferSize(): number;
213
- }
16
+ export type ErrnoError = Exception;
17
+ export declare function withPath<E extends Exception>(e: E, path: string): E;
18
+ export declare function wrap<const FS, const Prop extends keyof FS & string>(fs: FS, prop: Prop, path: string, dest?: string): FS[Prop];