bare-fs 4.0.1 → 4.0.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.
package/index.js CHANGED
@@ -1,58 +1,12 @@
1
- /* global Bare */
2
1
  const EventEmitter = require('bare-events')
3
2
  const path = require('bare-path')
4
3
  const { Readable, Writable } = require('bare-stream')
5
4
  const binding = require('./binding')
5
+ const constants = require('./lib/constants')
6
6
 
7
7
  const isWindows = Bare.platform === 'win32'
8
8
 
9
- const constants = (exports.constants = {
10
- O_RDWR: binding.O_RDWR,
11
- O_RDONLY: binding.O_RDONLY,
12
- O_WRONLY: binding.O_WRONLY,
13
- O_CREAT: binding.O_CREAT,
14
- O_TRUNC: binding.O_TRUNC,
15
- O_APPEND: binding.O_APPEND,
16
-
17
- F_OK: binding.F_OK || 0,
18
- R_OK: binding.R_OK || 0,
19
- W_OK: binding.W_OK || 0,
20
- X_OK: binding.X_OK || 0,
21
-
22
- S_IFMT: binding.S_IFMT,
23
- S_IFREG: binding.S_IFREG,
24
- S_IFDIR: binding.S_IFDIR,
25
- S_IFCHR: binding.S_IFCHR,
26
- S_IFLNK: binding.S_IFLNK,
27
- S_IFBLK: binding.S_IFBLK || 0,
28
- S_IFIFO: binding.S_IFIFO || 0,
29
- S_IFSOCK: binding.S_IFSOCK || 0,
30
-
31
- S_IRUSR: binding.S_IRUSR || 0,
32
- S_IWUSR: binding.S_IWUSR || 0,
33
- S_IXUSR: binding.S_IXUSR || 0,
34
- S_IRGRP: binding.S_IRGRP || 0,
35
- S_IWGRP: binding.S_IWGRP || 0,
36
- S_IXGRP: binding.S_IXGRP || 0,
37
- S_IROTH: binding.S_IROTH || 0,
38
- S_IWOTH: binding.S_IWOTH || 0,
39
- S_IXOTH: binding.S_IXOTH || 0,
40
-
41
- UV_DIRENT_UNKNOWN: binding.UV_DIRENT_UNKNOWN,
42
- UV_DIRENT_FILE: binding.UV_DIRENT_FILE,
43
- UV_DIRENT_DIR: binding.UV_DIRENT_DIR,
44
- UV_DIRENT_LINK: binding.UV_DIRENT_LINK,
45
- UV_DIRENT_FIFO: binding.UV_DIRENT_FIFO,
46
- UV_DIRENT_SOCKET: binding.UV_DIRENT_SOCKET,
47
- UV_DIRENT_CHAR: binding.UV_DIRENT_CHAR,
48
- UV_DIRENT_BLOCK: binding.UV_DIRENT_BLOCK,
49
-
50
- COPYFILE_EXCL: binding.UV_FS_COPYFILE_EXCL,
51
- COPYFILE_FICLONE: binding.UV_FS_COPYFILE_FICLONE,
52
- COPYFILE_FICLONE_FORCE: binding.UV_FS_COPYFILE_FICLONE_FORCE,
53
- UV_FS_SYMLINK_DIR: binding.UV_FS_SYMLINK_DIR,
54
- UV_FS_SYMLINK_JUNCTION: binding.UV_FS_SYMLINK_JUNCTION
55
- })
9
+ exports.constants = constants
56
10
 
57
11
  // Lightly-modified from the Node FS internal utils.
58
12
  function flagsToNumber(flags) {
@@ -2362,9 +2316,9 @@ class Dir {
2362
2316
 
2363
2317
  class Dirent {
2364
2318
  constructor(path, name, type) {
2365
- this.type = type
2366
2319
  this.path = path
2367
2320
  this.name = name
2321
+ this.type = type
2368
2322
  }
2369
2323
 
2370
2324
  isFile() {
@@ -0,0 +1,49 @@
1
+ declare const constants: {
2
+ O_RDWR: number
3
+ O_RDONLY: number
4
+ O_WRONLY: number
5
+ O_CREAT: number
6
+ O_TRUNC: number
7
+ O_APPEND: number
8
+
9
+ F_OK: number
10
+ R_OK: number
11
+ W_OK: number
12
+ X_OK: number
13
+
14
+ S_IFMT: number
15
+ S_IFREG: number
16
+ S_IFDIR: number
17
+ S_IFCHR: number
18
+ S_IFLNK: number
19
+ S_IFBLK: number
20
+ S_IFIFO: number
21
+ S_IFSOCK: number
22
+
23
+ S_IRUSR: number
24
+ S_IWUSR: number
25
+ S_IXUSR: number
26
+ S_IRGRP: number
27
+ S_IWGRP: number
28
+ S_IXGRP: number
29
+ S_IROTH: number
30
+ S_IWOTH: number
31
+ S_IXOTH: number
32
+
33
+ UV_DIRENT_UNKNOWN: number
34
+ UV_DIRENT_FILE: number
35
+ UV_DIRENT_DIR: number
36
+ UV_DIRENT_LINK: number
37
+ UV_DIRENT_FIFO: number
38
+ UV_DIRENT_SOCKET: number
39
+ UV_DIRENT_CHAR: number
40
+ UV_DIRENT_BLOCK: number
41
+
42
+ COPYFILE_EXCL: number
43
+ COPYFILE_FICLONE: number
44
+ COPYFILE_FICLONE_FORCE: number
45
+ UV_FS_SYMLINK_DIR: number
46
+ UV_FS_SYMLINK_JUNCTION: number
47
+ }
48
+
49
+ export = constants
@@ -0,0 +1,49 @@
1
+ const binding = require('../binding')
2
+
3
+ module.exports = {
4
+ O_RDWR: binding.O_RDWR,
5
+ O_RDONLY: binding.O_RDONLY,
6
+ O_WRONLY: binding.O_WRONLY,
7
+ O_CREAT: binding.O_CREAT,
8
+ O_TRUNC: binding.O_TRUNC,
9
+ O_APPEND: binding.O_APPEND,
10
+
11
+ F_OK: binding.F_OK || 0,
12
+ R_OK: binding.R_OK || 0,
13
+ W_OK: binding.W_OK || 0,
14
+ X_OK: binding.X_OK || 0,
15
+
16
+ S_IFMT: binding.S_IFMT,
17
+ S_IFREG: binding.S_IFREG,
18
+ S_IFDIR: binding.S_IFDIR,
19
+ S_IFCHR: binding.S_IFCHR,
20
+ S_IFLNK: binding.S_IFLNK,
21
+ S_IFBLK: binding.S_IFBLK || 0,
22
+ S_IFIFO: binding.S_IFIFO || 0,
23
+ S_IFSOCK: binding.S_IFSOCK || 0,
24
+
25
+ S_IRUSR: binding.S_IRUSR || 0,
26
+ S_IWUSR: binding.S_IWUSR || 0,
27
+ S_IXUSR: binding.S_IXUSR || 0,
28
+ S_IRGRP: binding.S_IRGRP || 0,
29
+ S_IWGRP: binding.S_IWGRP || 0,
30
+ S_IXGRP: binding.S_IXGRP || 0,
31
+ S_IROTH: binding.S_IROTH || 0,
32
+ S_IWOTH: binding.S_IWOTH || 0,
33
+ S_IXOTH: binding.S_IXOTH || 0,
34
+
35
+ UV_DIRENT_UNKNOWN: binding.UV_DIRENT_UNKNOWN,
36
+ UV_DIRENT_FILE: binding.UV_DIRENT_FILE,
37
+ UV_DIRENT_DIR: binding.UV_DIRENT_DIR,
38
+ UV_DIRENT_LINK: binding.UV_DIRENT_LINK,
39
+ UV_DIRENT_FIFO: binding.UV_DIRENT_FIFO,
40
+ UV_DIRENT_SOCKET: binding.UV_DIRENT_SOCKET,
41
+ UV_DIRENT_CHAR: binding.UV_DIRENT_CHAR,
42
+ UV_DIRENT_BLOCK: binding.UV_DIRENT_BLOCK,
43
+
44
+ COPYFILE_EXCL: binding.UV_FS_COPYFILE_EXCL,
45
+ COPYFILE_FICLONE: binding.UV_FS_COPYFILE_FICLONE,
46
+ COPYFILE_FICLONE_FORCE: binding.UV_FS_COPYFILE_FICLONE_FORCE,
47
+ UV_FS_SYMLINK_DIR: binding.UV_FS_SYMLINK_DIR,
48
+ UV_FS_SYMLINK_JUNCTION: binding.UV_FS_SYMLINK_JUNCTION
49
+ }
package/package.json CHANGED
@@ -1,14 +1,31 @@
1
1
  {
2
2
  "name": "bare-fs",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "Native file system for Javascript",
5
- "main": "index.js",
5
+ "exports": {
6
+ "./package": "./package.json",
7
+ ".": {
8
+ "types": "./index.d.ts",
9
+ "default": "./index.js"
10
+ },
11
+ "./promises": {
12
+ "types": "./promises.d.ts",
13
+ "default": "./promises.js"
14
+ },
15
+ "./constants": {
16
+ "types": "./lib/constants.d.ts",
17
+ "default": "./lib/constants.js"
18
+ }
19
+ },
6
20
  "files": [
7
21
  "index.js",
22
+ "index.d.ts",
8
23
  "promises.js",
24
+ "promises.d.ts",
9
25
  "binding.c",
10
26
  "binding.js",
11
27
  "CMakeLists.txt",
28
+ "lib",
12
29
  "prebuilds"
13
30
  ],
14
31
  "addon": true,
@@ -26,17 +43,26 @@
26
43
  },
27
44
  "homepage": "https://github.com/holepunchto/bare-fs#readme",
28
45
  "engines": {
29
- "bare": ">=1.7.0"
46
+ "bare": ">=1.16.0"
30
47
  },
31
48
  "dependencies": {
32
- "bare-events": "^2.0.0",
49
+ "bare-events": "^2.5.4",
33
50
  "bare-path": "^3.0.0",
34
- "bare-stream": "^2.0.0"
51
+ "bare-stream": "^2.6.4"
35
52
  },
36
53
  "devDependencies": {
54
+ "bare-buffer": "^3.0.2",
37
55
  "brittle": "^3.1.1",
38
56
  "cmake-bare": "^1.1.7",
39
57
  "prettier": "^3.4.1",
40
58
  "prettier-config-standard": "^7.0.0"
59
+ },
60
+ "peerDependencies": {
61
+ "bare-buffer": "*"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "bare-buffer": {
65
+ "optional": true
66
+ }
41
67
  }
42
68
  }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/promises.d.ts ADDED
@@ -0,0 +1,269 @@
1
+ import Buffer, { BufferEncoding } from 'bare-buffer'
2
+ import fs, {
3
+ AppendFileOptions,
4
+ Dir,
5
+ MkdirOptions,
6
+ OpendirOptions,
7
+ ReadFileOptions,
8
+ ReaddirOptions,
9
+ ReadlinkOptions,
10
+ RealpathOptions,
11
+ RmOptions,
12
+ Stats,
13
+ Watcher,
14
+ WatcherOptions,
15
+ WriteFileOptions
16
+ } from '.'
17
+
18
+ export function access(filepath: string, mode?: number): Promise<void>
19
+
20
+ export function appendFile(
21
+ filepath: string,
22
+ data: string | Buffer | ArrayBufferView,
23
+ opts?: AppendFileOptions
24
+ ): Promise<void>
25
+
26
+ export function appendFile(
27
+ filepath: string,
28
+ data: string | Buffer | ArrayBufferView,
29
+ encoding: BufferEncoding
30
+ ): Promise<void>
31
+
32
+ export function chmod(filepath: string, mode: string | number): Promise<void>
33
+
34
+ export function copyFile(src: string, dst: string, mode?: number): Promise<void>
35
+
36
+ export function lstat(filepath: string): Promise<Stats>
37
+
38
+ export function mkdir(filepath: string, opts?: MkdirOptions): Promise<void>
39
+
40
+ export function mkdir(filepath: string, mode: number): Promise<void>
41
+
42
+ export function opendir(
43
+ filepath: string,
44
+ opts: OpendirOptions & { encoding?: BufferEncoding }
45
+ ): Promise<Dir<string>>
46
+
47
+ export function opendir(
48
+ filepath: string,
49
+ opts: OpendirOptions & { encoding: 'buffer' }
50
+ ): Promise<Dir<Buffer>>
51
+
52
+ export function opendir(filepath: string, opts: OpendirOptions): Promise<Dir>
53
+
54
+ export function opendir(
55
+ filepath: string,
56
+ encoding: BufferEncoding
57
+ ): Promise<Dir<string>>
58
+
59
+ export function opendir(
60
+ filepath: string,
61
+ encoding: 'buffer'
62
+ ): Promise<Dir<Buffer>>
63
+
64
+ export function opendir(
65
+ filepath: string,
66
+ encoding: BufferEncoding | 'buffer'
67
+ ): Promise<Dir>
68
+
69
+ export function opendir(filepath: string): Promise<Dir<string>>
70
+
71
+ export function readFile(
72
+ filepath: string,
73
+ opts: ReadFileOptions & { encoding: BufferEncoding }
74
+ ): Promise<string>
75
+
76
+ export function readFile(
77
+ filepath: string,
78
+ opts: ReadFileOptions & { encoding?: 'buffer' }
79
+ ): Promise<Buffer>
80
+
81
+ export function readFile(
82
+ filepath: string,
83
+ opts: ReadFileOptions
84
+ ): Promise<string | Buffer>
85
+
86
+ export function readFile(
87
+ filepath: string,
88
+ encoding: BufferEncoding
89
+ ): Promise<string>
90
+
91
+ export function readFile(filepath: string, encoding: 'buffer'): Promise<Buffer>
92
+
93
+ export function readFile(
94
+ filepath: string,
95
+ encoding?: BufferEncoding | 'buffer'
96
+ ): Promise<string | Buffer>
97
+
98
+ export function readFile(filepath: string): Promise<Buffer>
99
+
100
+ export function readdir(
101
+ filepath: string,
102
+ opts: ReaddirOptions & { encoding?: BufferEncoding }
103
+ ): Promise<Dir<string>[] | string[]>
104
+
105
+ export function readdir(
106
+ filepath: string,
107
+ opts: ReaddirOptions & { encoding?: BufferEncoding; withFileTypes: true }
108
+ ): Promise<Dir<string>[]>
109
+
110
+ export function readdir(
111
+ filepath: string,
112
+ opts: ReaddirOptions & { encoding?: BufferEncoding; withFileTypes?: false }
113
+ ): Promise<string[]>
114
+
115
+ export function readdir(
116
+ filepath: string,
117
+ opts: ReaddirOptions & { encoding: 'buffer' }
118
+ ): Promise<Dir<Buffer>[] | Buffer[]>
119
+
120
+ export function readdir(
121
+ filepath: string,
122
+ opts: ReaddirOptions & { encoding: 'buffer'; withFileTypes: true }
123
+ ): Promise<Dir<Buffer>[]>
124
+
125
+ export function readdir(
126
+ filepath: string,
127
+ opts: ReaddirOptions & { encoding: 'buffer'; withFileTypes?: false }
128
+ ): Promise<Buffer[]>
129
+
130
+ export function readdir(
131
+ filepath: string,
132
+ opts: ReaddirOptions & { withFileTypes: true }
133
+ ): Promise<Dir<string | Buffer>[]>
134
+
135
+ export function readdir(
136
+ filepath: string,
137
+ opts: ReaddirOptions & { withFileTypes?: false }
138
+ ): Promise<string[] | Buffer[]>
139
+
140
+ export function readdir(
141
+ filepath: string,
142
+ opts: ReaddirOptions
143
+ ): Promise<Dir[] | string[] | Buffer[]>
144
+
145
+ export function readdir(
146
+ filepath: string,
147
+ encoding: BufferEncoding
148
+ ): Promise<string[]>
149
+
150
+ export function readdir(filepath: string, encoding: 'buffer'): Promise<Buffer[]>
151
+
152
+ export function readdir(
153
+ filepath: string,
154
+ encoding: BufferEncoding | 'buffer'
155
+ ): Promise<string[] | Buffer[]>
156
+
157
+ export function readdir(filepath: string): Promise<string[]>
158
+
159
+ export function readlink(
160
+ filepath: string,
161
+ opts: ReadlinkOptions & { encoding?: BufferEncoding }
162
+ ): Promise<string>
163
+
164
+ export function readlink(
165
+ filepath: string,
166
+ opts: ReadlinkOptions & { encoding: 'buffer' }
167
+ ): Promise<Buffer>
168
+
169
+ export function readlink(
170
+ filepath: string,
171
+ opts: ReadlinkOptions
172
+ ): Promise<string | Buffer>
173
+
174
+ export function readlink(
175
+ filepath: string,
176
+ encoding: BufferEncoding
177
+ ): Promise<string>
178
+
179
+ export function readlink(filepath: string, encoding: 'buffer'): Promise<Buffer>
180
+
181
+ export function readlink(
182
+ filepath: string,
183
+ encoding: BufferEncoding | 'buffer'
184
+ ): Promise<string | Buffer>
185
+
186
+ export function readlink(filepath: string): Promise<string>
187
+
188
+ export function realpath(
189
+ filepath: string,
190
+ opts: RealpathOptions & { encoding?: BufferEncoding }
191
+ ): Promise<string>
192
+
193
+ export function realpath(
194
+ filepath: string,
195
+ opts: RealpathOptions & { encoding: 'buffer' }
196
+ ): Promise<Buffer>
197
+
198
+ export function realpath(
199
+ filepath: string,
200
+ opts: RealpathOptions
201
+ ): Promise<string | Buffer>
202
+
203
+ export function realpath(
204
+ filepath: string,
205
+ encoding: BufferEncoding
206
+ ): Promise<string>
207
+
208
+ export function realpath(filepath: string, encoding: 'buffer'): Promise<Buffer>
209
+
210
+ export function realpath(
211
+ filepath: string,
212
+ encoding: BufferEncoding | 'buffer'
213
+ ): Promise<string | Buffer>
214
+
215
+ export function realpath(filepath: string): Promise<string>
216
+
217
+ export function rename(src: string, dst: string): Promise<void>
218
+
219
+ export function rm(filepath: string, opts?: RmOptions): Promise<void>
220
+
221
+ export function rmdir(filepath: string): Promise<void>
222
+
223
+ export function stat(filepath: string): Promise<Stats>
224
+
225
+ export function symlink(
226
+ target: string,
227
+ filepath: string,
228
+ type?: string | number
229
+ ): Promise<void>
230
+
231
+ export function unlink(filepath: string): Promise<void>
232
+
233
+ export function watch(
234
+ filepath: string,
235
+ opts: WatcherOptions & { encoding?: BufferEncoding }
236
+ ): Watcher<string>
237
+
238
+ export function watch(
239
+ filepath: string,
240
+ opts: WatcherOptions & { encoding: 'buffer' }
241
+ ): Watcher<Buffer>
242
+
243
+ export function watch(filepath: string, opts: WatcherOptions): Watcher
244
+
245
+ export function watch(
246
+ filepath: string,
247
+ encoding: BufferEncoding
248
+ ): Watcher<string>
249
+
250
+ export function watch(filepath: string, encoding: 'buffer'): Watcher<Buffer>
251
+
252
+ export function watch(
253
+ filepath: string,
254
+ encoding: BufferEncoding | 'buffer'
255
+ ): Watcher
256
+
257
+ export function watch(filepath: string): Watcher<string>
258
+
259
+ export function writeFile(
260
+ filepath: string,
261
+ data: string | Buffer | ArrayBufferView,
262
+ opts?: WriteFileOptions
263
+ ): Promise<void>
264
+
265
+ export function writeFile(
266
+ filepath: string,
267
+ data: string | Buffer | ArrayBufferView,
268
+ encoding: BufferEncoding
269
+ ): Promise<void>