memfs 4.55.0 → 4.56.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 (285) hide show
  1. package/README.md +75 -2
  2. package/lib/fsa/index.d.ts +1 -33
  3. package/lib/fsa/index.js +1 -39
  4. package/lib/fsa/index.js.map +1 -1
  5. package/lib/fsa-to-node/index.d.ts +1 -2
  6. package/lib/fsa-to-node/index.js +2 -5
  7. package/lib/fsa-to-node/index.js.map +1 -1
  8. package/lib/index.d.ts +6 -7
  9. package/lib/index.js +10 -14
  10. package/lib/index.js.map +1 -1
  11. package/lib/node-to-fsa/index.d.ts +1 -7
  12. package/lib/node-to-fsa/index.js +1 -10
  13. package/lib/node-to-fsa/index.js.map +1 -1
  14. package/package.json +9 -3
  15. package/lib/constants.d.ts +0 -67
  16. package/lib/constants.js +0 -54
  17. package/lib/constants.js.map +0 -1
  18. package/lib/consts/AMODE.d.ts +0 -9
  19. package/lib/consts/AMODE.js +0 -3
  20. package/lib/consts/AMODE.js.map +0 -1
  21. package/lib/consts/FLAG.d.ts +0 -53
  22. package/lib/consts/FLAG.js +0 -36
  23. package/lib/consts/FLAG.js.map +0 -1
  24. package/lib/core/File.d.ts +0 -39
  25. package/lib/core/File.js +0 -72
  26. package/lib/core/File.js.map +0 -1
  27. package/lib/core/Link.d.ts +0 -38
  28. package/lib/core/Link.js +0 -105
  29. package/lib/core/Link.js.map +0 -1
  30. package/lib/core/Node.d.ts +0 -85
  31. package/lib/core/Node.js +0 -287
  32. package/lib/core/Node.js.map +0 -1
  33. package/lib/core/Superblock.d.ts +0 -92
  34. package/lib/core/Superblock.js +0 -689
  35. package/lib/core/Superblock.js.map +0 -1
  36. package/lib/core/constants.d.ts +0 -15
  37. package/lib/core/constants.js +0 -3
  38. package/lib/core/constants.js.map +0 -1
  39. package/lib/core/index.d.ts +0 -6
  40. package/lib/core/index.js +0 -15
  41. package/lib/core/index.js.map +0 -1
  42. package/lib/core/json.d.ts +0 -9
  43. package/lib/core/json.js +0 -35
  44. package/lib/core/json.js.map +0 -1
  45. package/lib/core/result.d.ts +0 -11
  46. package/lib/core/result.js +0 -11
  47. package/lib/core/result.js.map +0 -1
  48. package/lib/core/types.d.ts +0 -8
  49. package/lib/core/types.js +0 -3
  50. package/lib/core/types.js.map +0 -1
  51. package/lib/core/util.d.ts +0 -12
  52. package/lib/core/util.js +0 -74
  53. package/lib/core/util.js.map +0 -1
  54. package/lib/encoding.d.ts +0 -6
  55. package/lib/encoding.js +0 -20
  56. package/lib/encoding.js.map +0 -1
  57. package/lib/fsa/CoreFileSystemDirectoryHandle.d.ts +0 -73
  58. package/lib/fsa/CoreFileSystemDirectoryHandle.js +0 -265
  59. package/lib/fsa/CoreFileSystemDirectoryHandle.js.map +0 -1
  60. package/lib/fsa/CoreFileSystemFileHandle.d.ts +0 -25
  61. package/lib/fsa/CoreFileSystemFileHandle.js +0 -75
  62. package/lib/fsa/CoreFileSystemFileHandle.js.map +0 -1
  63. package/lib/fsa/CoreFileSystemHandle.d.ts +0 -34
  64. package/lib/fsa/CoreFileSystemHandle.js +0 -53
  65. package/lib/fsa/CoreFileSystemHandle.js.map +0 -1
  66. package/lib/fsa/CoreFileSystemObserver.d.ts +0 -10
  67. package/lib/fsa/CoreFileSystemObserver.js +0 -18
  68. package/lib/fsa/CoreFileSystemObserver.js.map +0 -1
  69. package/lib/fsa/CoreFileSystemSyncAccessHandle.d.ts +0 -38
  70. package/lib/fsa/CoreFileSystemSyncAccessHandle.js +0 -123
  71. package/lib/fsa/CoreFileSystemSyncAccessHandle.js.map +0 -1
  72. package/lib/fsa/CoreFileSystemWritableFileStream.d.ts +0 -32
  73. package/lib/fsa/CoreFileSystemWritableFileStream.js +0 -163
  74. package/lib/fsa/CoreFileSystemWritableFileStream.js.map +0 -1
  75. package/lib/fsa/CorePermissionStatus.d.ts +0 -9
  76. package/lib/fsa/CorePermissionStatus.js +0 -14
  77. package/lib/fsa/CorePermissionStatus.js.map +0 -1
  78. package/lib/fsa/FileLockManager.d.ts +0 -7
  79. package/lib/fsa/FileLockManager.js +0 -26
  80. package/lib/fsa/FileLockManager.js.map +0 -1
  81. package/lib/fsa/types.d.ts +0 -182
  82. package/lib/fsa/types.js +0 -3
  83. package/lib/fsa/types.js.map +0 -1
  84. package/lib/fsa/util.d.ts +0 -12
  85. package/lib/fsa/util.js +0 -45
  86. package/lib/fsa/util.js.map +0 -1
  87. package/lib/fsa-to-node/FsaNodeCore.d.ts +0 -33
  88. package/lib/fsa-to-node/FsaNodeCore.js +0 -191
  89. package/lib/fsa-to-node/FsaNodeCore.js.map +0 -1
  90. package/lib/fsa-to-node/FsaNodeDirent.d.ts +0 -19
  91. package/lib/fsa-to-node/FsaNodeDirent.js +0 -39
  92. package/lib/fsa-to-node/FsaNodeDirent.js.map +0 -1
  93. package/lib/fsa-to-node/FsaNodeFs.d.ts +0 -187
  94. package/lib/fsa-to-node/FsaNodeFs.js +0 -831
  95. package/lib/fsa-to-node/FsaNodeFs.js.map +0 -1
  96. package/lib/fsa-to-node/FsaNodeFsOpenFile.d.ts +0 -24
  97. package/lib/fsa-to-node/FsaNodeFsOpenFile.js +0 -37
  98. package/lib/fsa-to-node/FsaNodeFsOpenFile.js.map +0 -1
  99. package/lib/fsa-to-node/FsaNodeReadStream.d.ts +0 -23
  100. package/lib/fsa-to-node/FsaNodeReadStream.js +0 -92
  101. package/lib/fsa-to-node/FsaNodeReadStream.js.map +0 -1
  102. package/lib/fsa-to-node/FsaNodeStats.d.ts +0 -30
  103. package/lib/fsa-to-node/FsaNodeStats.js +0 -53
  104. package/lib/fsa-to-node/FsaNodeStats.js.map +0 -1
  105. package/lib/fsa-to-node/FsaNodeWriteStream.d.ts +0 -47
  106. package/lib/fsa-to-node/FsaNodeWriteStream.js +0 -150
  107. package/lib/fsa-to-node/FsaNodeWriteStream.js.map +0 -1
  108. package/lib/fsa-to-node/constants.d.ts +0 -3
  109. package/lib/fsa-to-node/constants.js +0 -3
  110. package/lib/fsa-to-node/constants.js.map +0 -1
  111. package/lib/fsa-to-node/json.d.ts +0 -2
  112. package/lib/fsa-to-node/json.js +0 -7
  113. package/lib/fsa-to-node/json.js.map +0 -1
  114. package/lib/fsa-to-node/types.d.ts +0 -37
  115. package/lib/fsa-to-node/types.js +0 -3
  116. package/lib/fsa-to-node/types.js.map +0 -1
  117. package/lib/fsa-to-node/util.d.ts +0 -4
  118. package/lib/fsa-to-node/util.js +0 -34
  119. package/lib/fsa-to-node/util.js.map +0 -1
  120. package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.d.ts +0 -10
  121. package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js +0 -62
  122. package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js.map +0 -1
  123. package/lib/fsa-to-node/worker/FsaNodeSyncWorker.d.ts +0 -20
  124. package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js +0 -178
  125. package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js.map +0 -1
  126. package/lib/fsa-to-node/worker/SyncMessenger.d.ts +0 -24
  127. package/lib/fsa-to-node/worker/SyncMessenger.js +0 -72
  128. package/lib/fsa-to-node/worker/SyncMessenger.js.map +0 -1
  129. package/lib/fsa-to-node/worker/constants.d.ts +0 -8
  130. package/lib/fsa-to-node/worker/constants.js +0 -3
  131. package/lib/fsa-to-node/worker/constants.js.map +0 -1
  132. package/lib/fsa-to-node/worker/types.d.ts +0 -17
  133. package/lib/fsa-to-node/worker/types.js +0 -3
  134. package/lib/fsa-to-node/worker/types.js.map +0 -1
  135. package/lib/node/Dir.d.ts +0 -26
  136. package/lib/node/Dir.js +0 -186
  137. package/lib/node/Dir.js.map +0 -1
  138. package/lib/node/Dirent.d.ts +0 -26
  139. package/lib/node/Dirent.js +0 -57
  140. package/lib/node/Dirent.js.map +0 -1
  141. package/lib/node/FileHandle.d.ts +0 -52
  142. package/lib/node/FileHandle.js +0 -189
  143. package/lib/node/FileHandle.js.map +0 -1
  144. package/lib/node/FsPromises.d.ts +0 -91
  145. package/lib/node/FsPromises.js +0 -161
  146. package/lib/node/FsPromises.js.map +0 -1
  147. package/lib/node/StatFs.d.ts +0 -19
  148. package/lib/node/StatFs.js +0 -34
  149. package/lib/node/StatFs.js.map +0 -1
  150. package/lib/node/Stats.d.ts +0 -41
  151. package/lib/node/Stats.js +0 -72
  152. package/lib/node/Stats.js.map +0 -1
  153. package/lib/node/constants.d.ts +0 -41
  154. package/lib/node/constants.js +0 -57
  155. package/lib/node/constants.js.map +0 -1
  156. package/lib/node/glob.d.ts +0 -5
  157. package/lib/node/glob.js +0 -94
  158. package/lib/node/glob.js.map +0 -1
  159. package/lib/node/lists/fsCallbackApiList.d.ts +0 -2
  160. package/lib/node/lists/fsCallbackApiList.js +0 -55
  161. package/lib/node/lists/fsCallbackApiList.js.map +0 -1
  162. package/lib/node/lists/fsCommonObjectsList.d.ts +0 -2
  163. package/lib/node/lists/fsCommonObjectsList.js +0 -19
  164. package/lib/node/lists/fsCommonObjectsList.js.map +0 -1
  165. package/lib/node/lists/fsSynchronousApiList.d.ts +0 -2
  166. package/lib/node/lists/fsSynchronousApiList.js +0 -49
  167. package/lib/node/lists/fsSynchronousApiList.js.map +0 -1
  168. package/lib/node/options.d.ts +0 -27
  169. package/lib/node/options.js +0 -112
  170. package/lib/node/options.js.map +0 -1
  171. package/lib/node/types/FsCallbackApi.d.ts +0 -143
  172. package/lib/node/types/FsCallbackApi.js +0 -3
  173. package/lib/node/types/FsCallbackApi.js.map +0 -1
  174. package/lib/node/types/FsCommonObjects.d.ts +0 -17
  175. package/lib/node/types/FsCommonObjects.js +0 -3
  176. package/lib/node/types/FsCommonObjects.js.map +0 -1
  177. package/lib/node/types/FsPromisesApi.d.ts +0 -41
  178. package/lib/node/types/FsPromisesApi.js +0 -3
  179. package/lib/node/types/FsPromisesApi.js.map +0 -1
  180. package/lib/node/types/FsSynchronousApi.d.ts +0 -114
  181. package/lib/node/types/FsSynchronousApi.js +0 -3
  182. package/lib/node/types/FsSynchronousApi.js.map +0 -1
  183. package/lib/node/types/index.d.ts +0 -7
  184. package/lib/node/types/index.js +0 -3
  185. package/lib/node/types/index.js.map +0 -1
  186. package/lib/node/types/misc.d.ts +0 -157
  187. package/lib/node/types/misc.js +0 -3
  188. package/lib/node/types/misc.js.map +0 -1
  189. package/lib/node/types/options.d.ts +0 -191
  190. package/lib/node/types/options.js +0 -3
  191. package/lib/node/types/options.js.map +0 -1
  192. package/lib/node/util.d.ts +0 -21
  193. package/lib/node/util.js +0 -297
  194. package/lib/node/util.js.map +0 -1
  195. package/lib/node/volume.d.ts +0 -395
  196. package/lib/node/volume.js +0 -1641
  197. package/lib/node/volume.js.map +0 -1
  198. package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.d.ts +0 -72
  199. package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js +0 -217
  200. package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js.map +0 -1
  201. package/lib/node-to-fsa/NodeFileSystemFileHandle.d.ts +0 -28
  202. package/lib/node-to-fsa/NodeFileSystemFileHandle.js +0 -70
  203. package/lib/node-to-fsa/NodeFileSystemFileHandle.js.map +0 -1
  204. package/lib/node-to-fsa/NodeFileSystemHandle.d.ts +0 -37
  205. package/lib/node-to-fsa/NodeFileSystemHandle.js +0 -68
  206. package/lib/node-to-fsa/NodeFileSystemHandle.js.map +0 -1
  207. package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.d.ts +0 -42
  208. package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js +0 -97
  209. package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js.map +0 -1
  210. package/lib/node-to-fsa/NodeFileSystemWritableFileStream.d.ts +0 -56
  211. package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js +0 -191
  212. package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js.map +0 -1
  213. package/lib/node-to-fsa/NodePermissionStatus.d.ts +0 -8
  214. package/lib/node-to-fsa/NodePermissionStatus.js +0 -14
  215. package/lib/node-to-fsa/NodePermissionStatus.js.map +0 -1
  216. package/lib/node-to-fsa/types.d.ts +0 -18
  217. package/lib/node-to-fsa/types.js +0 -3
  218. package/lib/node-to-fsa/types.js.map +0 -1
  219. package/lib/node-to-fsa/util.d.ts +0 -12
  220. package/lib/node-to-fsa/util.js +0 -45
  221. package/lib/node-to-fsa/util.js.map +0 -1
  222. package/lib/node.d.ts +0 -3
  223. package/lib/node.js +0 -10
  224. package/lib/node.js.map +0 -1
  225. package/lib/print/index.d.ts +0 -9
  226. package/lib/print/index.js +0 -49
  227. package/lib/print/index.js.map +0 -1
  228. package/lib/process.d.ts +0 -11
  229. package/lib/process.js +0 -40
  230. package/lib/process.js.map +0 -1
  231. package/lib/queueMicrotask.d.ts +0 -2
  232. package/lib/queueMicrotask.js +0 -6
  233. package/lib/queueMicrotask.js.map +0 -1
  234. package/lib/snapshot/async.d.ts +0 -3
  235. package/lib/snapshot/async.js +0 -59
  236. package/lib/snapshot/async.js.map +0 -1
  237. package/lib/snapshot/binary.d.ts +0 -6
  238. package/lib/snapshot/binary.js +0 -31
  239. package/lib/snapshot/binary.js.map +0 -1
  240. package/lib/snapshot/constants.d.ts +0 -5
  241. package/lib/snapshot/constants.js +0 -3
  242. package/lib/snapshot/constants.js.map +0 -1
  243. package/lib/snapshot/index.d.ts +0 -5
  244. package/lib/snapshot/index.js +0 -8
  245. package/lib/snapshot/index.js.map +0 -1
  246. package/lib/snapshot/json.d.ts +0 -10
  247. package/lib/snapshot/json.js +0 -31
  248. package/lib/snapshot/json.js.map +0 -1
  249. package/lib/snapshot/shared.d.ts +0 -2
  250. package/lib/snapshot/shared.js +0 -6
  251. package/lib/snapshot/shared.js.map +0 -1
  252. package/lib/snapshot/sync.d.ts +0 -3
  253. package/lib/snapshot/sync.js +0 -59
  254. package/lib/snapshot/sync.js.map +0 -1
  255. package/lib/snapshot/types.d.ts +0 -30
  256. package/lib/snapshot/types.js +0 -3
  257. package/lib/snapshot/types.js.map +0 -1
  258. package/lib/vendor/node/buffer.d.ts +0 -1
  259. package/lib/vendor/node/buffer.js +0 -6
  260. package/lib/vendor/node/buffer.js.map +0 -1
  261. package/lib/vendor/node/events.d.ts +0 -1
  262. package/lib/vendor/node/events.js +0 -6
  263. package/lib/vendor/node/events.js.map +0 -1
  264. package/lib/vendor/node/fs.d.ts +0 -6
  265. package/lib/vendor/node/fs.js +0 -4
  266. package/lib/vendor/node/fs.js.map +0 -1
  267. package/lib/vendor/node/internal/buffer.d.ts +0 -9
  268. package/lib/vendor/node/internal/buffer.js +0 -13
  269. package/lib/vendor/node/internal/buffer.js.map +0 -1
  270. package/lib/vendor/node/internal/errors.d.ts +0 -31
  271. package/lib/vendor/node/internal/errors.js +0 -77
  272. package/lib/vendor/node/internal/errors.js.map +0 -1
  273. package/lib/vendor/node/path.d.ts +0 -1
  274. package/lib/vendor/node/path.js +0 -14
  275. package/lib/vendor/node/path.js.map +0 -1
  276. package/lib/vendor/node/stream.d.ts +0 -1
  277. package/lib/vendor/node/stream.js +0 -7
  278. package/lib/vendor/node/stream.js.map +0 -1
  279. package/lib/vendor/node/url.d.ts +0 -1
  280. package/lib/vendor/node/url.js +0 -6
  281. package/lib/vendor/node/url.js.map +0 -1
  282. package/lib/vendor/node/util.d.ts +0 -20
  283. package/lib/vendor/node/util.js +0 -112
  284. package/lib/vendor/node/util.js.map +0 -1
  285. package/src/node-to-fsa/README.md +0 -5
@@ -1,157 +0,0 @@
1
- import type { PathLike as NodePathLike, symlink } from '../../vendor/node/fs';
2
- import type { constants } from '../../constants';
3
- import type { EventEmitter } from '../../vendor/node/events';
4
- import type { TSetTimeout } from '@jsonjoy.com/node-fs-utils/lib/setTimeoutUnref';
5
- import type { IAppendFileOptions, IFileHandleReadStreamOptions, IFileHandleWriteStreamOptions, IReadableWebStreamOptions, IReadFileOptions, IStatOptions, IWriteFileOptions } from './options';
6
- import type { Readable, Writable } from '../../vendor/node/stream';
7
- export { symlink };
8
- export type PathLike = NodePathLike | Uint8Array;
9
- export type TDataOut = string | Buffer;
10
- export type TEncodingExtended = BufferEncoding | 'buffer';
11
- export type TFileId = PathLike | number;
12
- export type TData = TDataOut | ArrayBufferView | DataView;
13
- export type TPromisesData = TData | Readable;
14
- export type TFlags = string | number;
15
- export type TMode = string | number;
16
- export type TTime = number | string | Date;
17
- export type TCallback<TData> = (error?: IError | null, data?: TData) => void;
18
- export type TCallback2<T1, T2> = (error: IError | null, bytesRead?: T1, buffers?: T2) => void;
19
- export interface IError extends Error {
20
- code?: string;
21
- }
22
- export type TFlagsCopy = typeof constants.COPYFILE_EXCL | typeof constants.COPYFILE_FICLONE | typeof constants.COPYFILE_FICLONE_FORCE;
23
- export type TStatNumber = number | bigint;
24
- export interface IStats<T = TStatNumber> {
25
- uid: T;
26
- gid: T;
27
- rdev: T;
28
- blksize: T;
29
- ino: T;
30
- size: T;
31
- blocks: T;
32
- atime: Date;
33
- mtime: Date;
34
- ctime: Date;
35
- birthtime: Date;
36
- atimeMs: T;
37
- mtimeMs: T;
38
- ctimeMs: T;
39
- birthtimeMs: T;
40
- dev: T;
41
- mode: T;
42
- nlink: T;
43
- isDirectory(): boolean;
44
- isFile(): boolean;
45
- isBlockDevice(): boolean;
46
- isCharacterDevice(): boolean;
47
- isSymbolicLink(): boolean;
48
- isFIFO(): boolean;
49
- isSocket(): boolean;
50
- }
51
- export interface IStatFs<T = TStatNumber> {
52
- bavail: T;
53
- bfree: T;
54
- blocks: T;
55
- bsize: T;
56
- ffree: T;
57
- files: T;
58
- type: T;
59
- }
60
- export interface IDir extends Disposable, AsyncDisposable {
61
- path: string;
62
- close(): Promise<void>;
63
- close(callback?: (err?: Error) => void): void;
64
- closeSync(): void;
65
- read(): Promise<IDirent | null>;
66
- read(callback?: (err: Error | null, dir?: IDirent | null) => void): void;
67
- readSync(): IDirent | null;
68
- [Symbol.asyncIterator](): AsyncIterableIterator<IDirent>;
69
- }
70
- export interface IDirent {
71
- name: TDataOut;
72
- /**
73
- * @deprecated
74
- * @see https://nodejs.org/api/deprecations.html#DEP0178
75
- */
76
- parent?: string;
77
- parentPath: string;
78
- isDirectory(): boolean;
79
- isFile(): boolean;
80
- isBlockDevice(): boolean;
81
- isCharacterDevice(): boolean;
82
- isSymbolicLink(): boolean;
83
- isFIFO(): boolean;
84
- isSocket(): boolean;
85
- }
86
- export interface IStatWatcher extends EventEmitter {
87
- filename: string;
88
- interval: number;
89
- timeoutRef?: any;
90
- setTimeout: TSetTimeout;
91
- prev: IStats;
92
- start(path: string, persistent?: boolean, interval?: number): void;
93
- stop(): void;
94
- }
95
- export interface IReadStream extends Readable {
96
- bytesRead: number;
97
- path: string | Buffer;
98
- pending: boolean;
99
- }
100
- export interface IWriteStream extends Writable {
101
- bytesWritten: number;
102
- path: string;
103
- pending: boolean;
104
- close(callback?: (err?: Error) => void): void;
105
- }
106
- export interface IFSWatcher extends EventEmitter {
107
- start(path: PathLike, persistent?: boolean, recursive?: boolean, encoding?: BufferEncoding): void;
108
- close(): void;
109
- }
110
- /**
111
- * Declare ReadableStream in case dom.d.ts is not added to the tsconfig lib causing
112
- * ReadableStream interface is not defined. For developers with dom.d.ts added,
113
- * the ReadableStream interface will be merged correctly.
114
- */
115
- declare global {
116
- export interface ReadableStream {
117
- }
118
- }
119
- export interface IFileHandle extends EventEmitter {
120
- fd: number;
121
- getAsyncId(): number;
122
- appendFile(data: TData, options?: IAppendFileOptions | string): Promise<void>;
123
- chmod(mode: TMode): Promise<void>;
124
- chown(uid: number, gid: number): Promise<void>;
125
- close(): Promise<void>;
126
- createReadStream(options: IFileHandleReadStreamOptions): IReadStream;
127
- createWriteStream(options: IFileHandleWriteStreamOptions): IWriteStream;
128
- datasync(): Promise<void>;
129
- readableWebStream(options?: IReadableWebStreamOptions): ReadableStream;
130
- read(buffer: Buffer | Uint8Array, offset: number, length: number, position?: number | null): Promise<TFileHandleReadResult>;
131
- readv(buffers: ArrayBufferView[], position?: number | null): Promise<TFileHandleReadvResult>;
132
- readFile(options?: IReadFileOptions | string): Promise<TDataOut>;
133
- stat(options?: IStatOptions): Promise<IStats>;
134
- truncate(len?: number): Promise<void>;
135
- utimes(atime: TTime, mtime: TTime): Promise<void>;
136
- write(buffer: Buffer | ArrayBufferView | DataView, offset?: number, length?: number, position?: number | null): Promise<TFileHandleWriteResult>;
137
- writev(buffers: ArrayBufferView[], position?: number | null): Promise<TFileHandleWritevResult>;
138
- writeFile(data: TData, options?: IWriteFileOptions): Promise<void>;
139
- }
140
- export type TFileHandle = PathLike | IFileHandle;
141
- export interface TFileHandleReadResult {
142
- bytesRead: number;
143
- buffer: Buffer | Uint8Array;
144
- }
145
- export interface TFileHandleWriteResult {
146
- bytesWritten: number;
147
- buffer: Buffer | Uint8Array;
148
- }
149
- export interface TFileHandleReadvResult {
150
- bytesRead: number;
151
- buffers: ArrayBufferView[];
152
- }
153
- export interface TFileHandleWritevResult {
154
- bytesWritten: number;
155
- buffers: ArrayBufferView[];
156
- }
157
- export type AssertCallback<T> = T extends () => void ? T : never;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=misc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"misc.js","sourceRoot":"","sources":["../../../src/node/types/misc.ts"],"names":[],"mappings":""}
@@ -1,191 +0,0 @@
1
- import type { IFileHandle, TEncodingExtended, TFlags, TMode } from './misc';
2
- export interface IOptions {
3
- encoding?: BufferEncoding | TEncodingExtended;
4
- }
5
- export interface IFileOptions extends IOptions {
6
- mode?: TMode;
7
- flag?: TFlags;
8
- }
9
- export interface IWriteFileOptions extends IFileOptions {
10
- }
11
- export interface IReadFileOptions extends IOptions {
12
- flag?: string;
13
- }
14
- export interface IRealpathOptions {
15
- encoding?: TEncodingExtended;
16
- }
17
- export interface IAppendFileOptions extends IFileOptions {
18
- }
19
- export interface IStatOptions {
20
- bigint?: boolean;
21
- throwIfNoEntry?: boolean;
22
- }
23
- export interface IFStatOptions {
24
- bigint?: boolean;
25
- }
26
- export interface IAppendFileOptions extends IFileOptions {
27
- }
28
- export interface IReadableWebStreamOptions {
29
- type?: 'bytes' | undefined;
30
- autoClose?: boolean;
31
- }
32
- export interface IFileHandleReadStreamOptions {
33
- encoding?: BufferEncoding;
34
- autoClose?: boolean;
35
- emitClose?: boolean;
36
- start?: number | undefined;
37
- end?: number;
38
- highWaterMark?: number;
39
- flush?: boolean;
40
- signal?: AbortSignal | undefined;
41
- }
42
- export interface IFileHandleWriteStreamOptions {
43
- encoding?: BufferEncoding;
44
- autoClose?: boolean;
45
- emitClose?: boolean;
46
- start?: number;
47
- highWaterMark?: number;
48
- flush?: boolean;
49
- }
50
- export interface IReaddirOptions extends IOptions {
51
- recursive?: boolean;
52
- withFileTypes?: boolean;
53
- }
54
- export interface IMkdirOptions {
55
- mode?: TMode;
56
- recursive?: boolean;
57
- }
58
- export interface IRmdirOptions {
59
- recursive?: boolean;
60
- maxRetries?: number;
61
- retryDelay?: number;
62
- }
63
- export interface IRmOptions {
64
- force?: boolean;
65
- maxRetries?: number;
66
- recursive?: boolean;
67
- retryDelay?: number;
68
- }
69
- export interface IWatchFileOptions {
70
- persistent?: boolean;
71
- interval?: number;
72
- }
73
- export interface IReadStreamOptions extends IOptions {
74
- /** Defaults to `'r'`. */
75
- flags?: TFlags;
76
- /** Defaults to `null`. */
77
- encoding?: BufferEncoding;
78
- /** Defaults to `null`. */
79
- fd?: number | IFileHandle | null;
80
- /** Defaults to 0o666 */
81
- mode?: TMode;
82
- /** Defaults to `true`. */
83
- autoClose?: boolean;
84
- /** Defaults to `true`. */
85
- emitClose?: boolean;
86
- start?: number;
87
- /** Defaults to `Infinity`. */
88
- end?: number;
89
- /** Defaults to `64 * 1024`. */
90
- highWaterMark?: number;
91
- /** Defaults to `null`. */
92
- fs?: object | null;
93
- /** Defaults to `null`. */
94
- signal?: AbortSignal | null;
95
- }
96
- export interface IWriteStreamOptions {
97
- flags?: TFlags;
98
- encoding?: BufferEncoding;
99
- fd?: number | IFileHandle;
100
- mode?: TMode;
101
- autoClose?: boolean;
102
- emitClose?: boolean;
103
- start?: number;
104
- }
105
- export interface IWatchOptions extends IOptions {
106
- /**
107
- * Indicates whether the process should continue to run as long as files are
108
- * being watched. Default: true.
109
- */
110
- persistent?: boolean;
111
- /**
112
- * Indicates whether all subdirectories should be watched, or only the current
113
- * directory. This applies when a directory is specified, and only on
114
- * supported platforms (See caveats). Default: false.
115
- */
116
- recursive?: boolean;
117
- /**
118
- * Allows closing the watcher with an {@link AbortSignal}.
119
- */
120
- signal?: AbortSignal;
121
- /**
122
- * Specifies the number of events to queue between iterations of the AsyncIterator.
123
- * Default: 2048.
124
- */
125
- maxQueue?: number;
126
- /**
127
- * Either 'ignore' or 'throw' when there are more events to be queued than maxQueue allows.
128
- * 'ignore' means overflow events are dropped and a warning is emitted, while 'throw'
129
- * means to throw an exception. Default: 'ignore'.
130
- */
131
- overflow?: 'ignore' | 'throw';
132
- }
133
- export interface ICpOptions {
134
- /** dereference symlinks. Default: false. */
135
- dereference?: boolean;
136
- /**
137
- * When force is false, and the destination exists, throw an error.
138
- * Default: false.
139
- */
140
- errorOnExist?: boolean;
141
- /**
142
- * Function to filter copied files/directories. Return true to copy the item,
143
- * false to ignore it. Default: undefined.
144
- */
145
- filter?: (src: string, dest: string) => boolean;
146
- /**
147
- * Overwrite existing file or directory. The copy operation will ignore errors
148
- * if you set this to false and the destination exists. Use the errorOnExist
149
- * option to change this behavior. Default: true.
150
- */
151
- force?: boolean;
152
- /**
153
- * Integer, modifiers for copy operation. Default: 0. See mode flag of
154
- * `fs.copyFileSync()`.
155
- */
156
- mode?: number;
157
- /** When true timestamps from src will be preserved. Default: false. */
158
- preserveTimestamps?: boolean;
159
- /** Copy directories recursively Default: false. */
160
- recursive?: boolean;
161
- /** When true, path resolution for symlinks will be skipped. Default: false. */
162
- verbatimSymlinks?: boolean;
163
- }
164
- export interface IStafsOptions {
165
- /** Whether the numeric values in the returned `StatFs` object should be bigint. */
166
- bigint?: boolean;
167
- }
168
- export interface IOpenAsBlobOptions {
169
- /** An optional mime type for the blob. */
170
- type?: string;
171
- }
172
- export interface IGlobOptions {
173
- /** Current working directory. */
174
- cwd?: string | URL;
175
- /** Exclude patterns. */
176
- exclude?: string | string[];
177
- /** Maximum search depth. */
178
- maxdepth?: number;
179
- /** Whether to include symbolic links. */
180
- withFileTypes?: boolean;
181
- }
182
- export interface IOpendirOptions extends IOptions {
183
- /**
184
- * Number of directory entries that are buffered internally when reading from
185
- * the directory. Higher values lead to better performance but higher memory
186
- * usage. Default: 32.
187
- */
188
- bufferSize?: number;
189
- /** Default: false. */
190
- recursive?: boolean;
191
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=options.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/node/types/options.ts"],"names":[],"mappings":""}
@@ -1,21 +0,0 @@
1
- import { Buffer } from '../vendor/node/internal/buffer';
2
- import { TEncodingExtended } from '../encoding';
3
- import { Readable } from '../vendor/node/stream';
4
- import type { FsCallbackApi } from './types';
5
- import type * as misc from './types/misc';
6
- import { StatError } from '../core/types';
7
- export declare function promisify(fs: FsCallbackApi, fn: string, getResult?: (result: any) => any): (...args: any[]) => Promise<any>;
8
- export declare function validateCallback<T>(callback: T): misc.AssertCallback<T>;
9
- export declare function modeToNumber(mode: misc.TMode | undefined, def?: any): number;
10
- export declare function nullCheck(path: any, callback?: any): boolean;
11
- export declare function pathToFilename(path: misc.PathLike): string;
12
- export declare function createError(errorCode: string, func?: string, path?: string, path2?: string, Constructor?: ErrorConstructor): Error;
13
- export declare function createStatError(errorCode: string, func?: string, path?: string, path2?: string): StatError;
14
- export declare function genRndStr6(): string;
15
- export declare function flagsToNumber(flags: misc.TFlags | undefined): number;
16
- export declare function streamToBuffer(stream: Readable): Promise<Buffer<ArrayBufferLike>>;
17
- export declare const bufToUint8: (buf: Buffer) => Uint8Array;
18
- export declare const getWriteArgs: (fd: number, a?: unknown, b?: unknown, c?: unknown, d?: unknown, e?: unknown) => [fd: number, dataAsStr: boolean, buf: Buffer, offset: number, length: number, position: number | null, callback: (...args: any) => void];
19
- export declare const getWriteSyncArgs: (fd: number, a: string | Buffer | ArrayBufferView | DataView, b?: number, c?: number | BufferEncoding, d?: number | null) => [fd: number, buf: Buffer, offset: number, length?: number, position?: number | null];
20
- export declare function bufferToEncoding(buffer: Buffer, encoding?: TEncodingExtended): misc.TDataOut;
21
- export declare function isReadableStream(stream: any): stream is Readable;
package/lib/node/util.js DELETED
@@ -1,297 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWriteSyncArgs = exports.getWriteArgs = exports.bufToUint8 = void 0;
4
- exports.promisify = promisify;
5
- exports.validateCallback = validateCallback;
6
- exports.modeToNumber = modeToNumber;
7
- exports.nullCheck = nullCheck;
8
- exports.pathToFilename = pathToFilename;
9
- exports.createError = createError;
10
- exports.createStatError = createStatError;
11
- exports.genRndStr6 = genRndStr6;
12
- exports.flagsToNumber = flagsToNumber;
13
- exports.streamToBuffer = streamToBuffer;
14
- exports.bufferToEncoding = bufferToEncoding;
15
- exports.isReadableStream = isReadableStream;
16
- const constants_1 = require("./constants");
17
- const errors = require("../vendor/node/internal/errors");
18
- const buffer_1 = require("../vendor/node/internal/buffer");
19
- const queueMicrotask_1 = require("../queueMicrotask");
20
- const util_1 = require("../core/util");
21
- function promisify(fs, fn, getResult = input => input) {
22
- return (...args) => new Promise((resolve, reject) => {
23
- fs[fn].bind(fs)(...args, (error, result) => {
24
- if (error)
25
- return reject(error);
26
- return resolve(getResult(result));
27
- });
28
- });
29
- }
30
- function validateCallback(callback) {
31
- if (typeof callback !== 'function')
32
- throw TypeError(constants_1.ERRSTR.CB);
33
- return callback;
34
- }
35
- function _modeToNumber(mode, def) {
36
- if (typeof mode === 'number')
37
- return mode;
38
- if (typeof mode === 'string')
39
- return parseInt(mode, 8);
40
- if (def)
41
- return modeToNumber(def);
42
- return undefined;
43
- }
44
- function modeToNumber(mode, def) {
45
- const result = _modeToNumber(mode, def);
46
- if (typeof result !== 'number' || isNaN(result))
47
- throw new TypeError(constants_1.ERRSTR.MODE_INT);
48
- return result;
49
- }
50
- function nullCheck(path, callback) {
51
- if (('' + path).indexOf('\u0000') !== -1) {
52
- const er = new Error('Path must be a string without null bytes');
53
- er.code = 'ENOENT';
54
- if (typeof callback !== 'function')
55
- throw er;
56
- (0, queueMicrotask_1.default)(() => {
57
- callback(er);
58
- });
59
- return false;
60
- }
61
- return true;
62
- }
63
- function getPathFromURLPosix(url) {
64
- if (url.hostname !== '') {
65
- throw new errors.TypeError('ERR_INVALID_FILE_URL_HOST', process.platform);
66
- }
67
- const pathname = url.pathname;
68
- for (let n = 0; n < pathname.length; n++) {
69
- if (pathname[n] === '%') {
70
- const third = pathname.codePointAt(n + 2) | 0x20;
71
- if (pathname[n + 1] === '2' && third === 102) {
72
- throw new errors.TypeError('ERR_INVALID_FILE_URL_PATH', 'must not include encoded / characters');
73
- }
74
- }
75
- }
76
- return decodeURIComponent(pathname);
77
- }
78
- function pathToFilename(path) {
79
- if (path instanceof Uint8Array) {
80
- path = (0, buffer_1.bufferFrom)(path);
81
- }
82
- if (typeof path !== 'string' && !buffer_1.Buffer.isBuffer(path)) {
83
- try {
84
- if (!(path instanceof require('url').URL))
85
- throw new TypeError(constants_1.ERRSTR.PATH_STR);
86
- }
87
- catch (err) {
88
- throw new TypeError(constants_1.ERRSTR.PATH_STR);
89
- }
90
- path = getPathFromURLPosix(path);
91
- }
92
- const pathString = String(path);
93
- nullCheck(pathString);
94
- // return slash(pathString);
95
- return pathString;
96
- }
97
- const ENOENT = 'ENOENT';
98
- const EBADF = 'EBADF';
99
- const EINVAL = 'EINVAL';
100
- const EPERM = 'EPERM';
101
- const EPROTO = 'EPROTO';
102
- const EEXIST = 'EEXIST';
103
- const ENOTDIR = 'ENOTDIR';
104
- const EMFILE = 'EMFILE';
105
- const EACCES = 'EACCES';
106
- const EISDIR = 'EISDIR';
107
- const ENOTEMPTY = 'ENOTEMPTY';
108
- const ENOSYS = 'ENOSYS';
109
- const ERR_FS_EISDIR = 'ERR_FS_EISDIR';
110
- const ERR_OUT_OF_RANGE = 'ERR_OUT_OF_RANGE';
111
- function formatError(errorCode, func = '', path = '', path2 = '') {
112
- let pathFormatted = '';
113
- if (path)
114
- pathFormatted = ` '${path}'`;
115
- if (path2)
116
- pathFormatted += ` -> '${path2}'`;
117
- switch (errorCode) {
118
- case ENOENT:
119
- return `ENOENT: no such file or directory, ${func}${pathFormatted}`;
120
- case EBADF:
121
- return `EBADF: bad file descriptor, ${func}${pathFormatted}`;
122
- case EINVAL:
123
- return `EINVAL: invalid argument, ${func}${pathFormatted}`;
124
- case EPERM:
125
- return `EPERM: operation not permitted, ${func}${pathFormatted}`;
126
- case EPROTO:
127
- return `EPROTO: protocol error, ${func}${pathFormatted}`;
128
- case EEXIST:
129
- return `EEXIST: file already exists, ${func}${pathFormatted}`;
130
- case ENOTDIR:
131
- return `ENOTDIR: not a directory, ${func}${pathFormatted}`;
132
- case EISDIR:
133
- return `EISDIR: illegal operation on a directory, ${func}${pathFormatted}`;
134
- case EACCES:
135
- return `EACCES: permission denied, ${func}${pathFormatted}`;
136
- case ENOTEMPTY:
137
- return `ENOTEMPTY: directory not empty, ${func}${pathFormatted}`;
138
- case EMFILE:
139
- return `EMFILE: too many open files, ${func}${pathFormatted}`;
140
- case ENOSYS:
141
- return `ENOSYS: function not implemented, ${func}${pathFormatted}`;
142
- case ERR_FS_EISDIR:
143
- return `[ERR_FS_EISDIR]: Path is a directory: ${func} returned EISDIR (is a directory) ${path}`;
144
- case ERR_OUT_OF_RANGE:
145
- return `[ERR_OUT_OF_RANGE]: value out of range, ${func}${pathFormatted}`;
146
- default:
147
- return `${errorCode}: error occurred, ${func}${pathFormatted}`;
148
- }
149
- }
150
- function createError(errorCode, func = '', path = '', path2 = '', Constructor = Error) {
151
- const error = new Constructor(formatError(errorCode, func, path, path2));
152
- error.code = errorCode;
153
- if (path) {
154
- error.path = path;
155
- }
156
- return error;
157
- }
158
- function createStatError(errorCode, func = '', path = '', path2 = '') {
159
- return {
160
- code: errorCode,
161
- message: formatError(errorCode, func, path, path2),
162
- path,
163
- toError() {
164
- const error = new Error(this.message);
165
- error.code = this.code;
166
- if (this.path) {
167
- error.path = this.path;
168
- }
169
- return error;
170
- },
171
- };
172
- }
173
- function genRndStr6() {
174
- return Math.random().toString(36).slice(2, 8).padEnd(6, '0');
175
- }
176
- function flagsToNumber(flags) {
177
- if (typeof flags === 'number')
178
- return flags;
179
- if (typeof flags === 'string') {
180
- const flagsNum = constants_1.FLAGS[flags];
181
- if (typeof flagsNum !== 'undefined')
182
- return flagsNum;
183
- }
184
- // throw new TypeError(formatError(ERRSTR_FLAG(flags)));
185
- throw new errors.TypeError('ERR_INVALID_OPT_VALUE', 'flags', flags);
186
- }
187
- function streamToBuffer(stream) {
188
- const chunks = [];
189
- return new Promise((resolve, reject) => {
190
- stream.on('data', chunk => chunks.push(chunk));
191
- stream.on('end', () => resolve(buffer_1.Buffer.concat(chunks)));
192
- stream.on('error', reject);
193
- });
194
- }
195
- const bufToUint8 = (buf) => new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
196
- exports.bufToUint8 = bufToUint8;
197
- const getWriteArgs = (fd, a, b, c, d, e) => {
198
- (0, util_1.validateFd)(fd);
199
- let offset = 0;
200
- let length;
201
- let position = null;
202
- let encoding;
203
- let callback;
204
- const tipa = typeof a;
205
- const tipb = typeof b;
206
- const tipc = typeof c;
207
- const tipd = typeof d;
208
- if (tipa !== 'string') {
209
- if (tipb === 'function') {
210
- callback = b;
211
- }
212
- else if (tipc === 'function') {
213
- offset = b | 0;
214
- callback = c;
215
- }
216
- else if (tipd === 'function') {
217
- offset = b | 0;
218
- length = c;
219
- callback = d;
220
- }
221
- else {
222
- offset = b | 0;
223
- length = c;
224
- position = d;
225
- callback = e;
226
- }
227
- }
228
- else {
229
- if (tipb === 'function') {
230
- callback = b;
231
- }
232
- else if (tipc === 'function') {
233
- position = b;
234
- callback = c;
235
- }
236
- else if (tipd === 'function') {
237
- position = b;
238
- encoding = c;
239
- callback = d;
240
- }
241
- }
242
- const buf = (0, util_1.dataToBuffer)(a, encoding);
243
- if (tipa !== 'string') {
244
- if (typeof length === 'undefined')
245
- length = buf.length;
246
- }
247
- else {
248
- offset = 0;
249
- length = buf.length;
250
- }
251
- const cb = validateCallback(callback);
252
- return [fd, tipa === 'string', buf, offset, length, position, cb];
253
- };
254
- exports.getWriteArgs = getWriteArgs;
255
- const getWriteSyncArgs = (fd, a, b, c, d) => {
256
- (0, util_1.validateFd)(fd);
257
- let encoding;
258
- let offset;
259
- let length;
260
- let position;
261
- const isBuffer = typeof a !== 'string';
262
- if (isBuffer) {
263
- offset = (b || 0) | 0;
264
- length = c;
265
- position = d;
266
- }
267
- else {
268
- position = b;
269
- encoding = c;
270
- }
271
- const buf = (0, util_1.dataToBuffer)(a, encoding);
272
- if (isBuffer) {
273
- if (typeof length === 'undefined') {
274
- length = buf.length;
275
- }
276
- }
277
- else {
278
- offset = 0;
279
- length = buf.length;
280
- }
281
- return [fd, buf, offset || 0, length, position];
282
- };
283
- exports.getWriteSyncArgs = getWriteSyncArgs;
284
- function bufferToEncoding(buffer, encoding) {
285
- if (!encoding || encoding === 'buffer')
286
- return buffer;
287
- else
288
- return buffer.toString(encoding);
289
- }
290
- function isReadableStream(stream) {
291
- return (stream !== null &&
292
- typeof stream === 'object' &&
293
- typeof stream.pipe === 'function' &&
294
- typeof stream.on === 'function' &&
295
- stream.readable === true);
296
- }
297
- //# sourceMappingURL=util.js.map