@fncts/node 0.0.43 → 0.0.45
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/LICENSE +26 -0
- package/_cjs/chunk.cjs +28 -0
- package/_cjs/fs/api.cjs +289 -276
- package/_cjs/fs/api.cjs.map +1 -1
- package/_cjs/fs.cjs +46 -17
- package/_cjs/global.cjs +0 -2
- package/_cjs/http/IncomingMessage.cjs +60 -55
- package/_cjs/http/IncomingMessage.cjs.map +1 -1
- package/_cjs/http/Server.cjs +180 -195
- package/_cjs/http/Server.cjs.map +1 -1
- package/_cjs/http/ServerRequest.cjs +41 -39
- package/_cjs/http/ServerRequest.cjs.map +1 -1
- package/_cjs/index.cjs +0 -2
- package/_cjs/stream/api.cjs +215 -220
- package/_cjs/stream/api.cjs.map +1 -1
- package/_cjs/stream.cjs +10 -17
- package/_mjs/fs/api.mjs +296 -300
- package/_mjs/fs/api.mjs.map +1 -1
- package/_mjs/fs.mjs +2 -3
- package/_mjs/global.mjs +0 -2
- package/_mjs/http/IncomingMessage.mjs +49 -45
- package/_mjs/http/IncomingMessage.mjs.map +1 -1
- package/_mjs/http/Server.mjs +139 -169
- package/_mjs/http/Server.mjs.map +1 -1
- package/_mjs/http/ServerRequest.mjs +36 -29
- package/_mjs/http/ServerRequest.mjs.map +1 -1
- package/_mjs/index.mjs +0 -2
- package/_mjs/stream/api.mjs +164 -187
- package/_mjs/stream/api.mjs.map +1 -1
- package/_mjs/stream.mjs +2 -3
- package/_src/fs/api.ts +8 -9
- package/_src/stream/api.ts +16 -0
- package/fs/api.d.ts +1 -1
- package/http/Server.d.ts +1 -1
- package/package.json +7 -3
- package/_cjs/fs.cjs.map +0 -1
- package/_cjs/global.cjs.map +0 -1
- package/_cjs/index.cjs.map +0 -1
- package/_cjs/stream.cjs.map +0 -1
- package/_mjs/fs.mjs.map +0 -1
- package/_mjs/global.mjs.map +0 -1
- package/_mjs/index.mjs.map +0 -1
- package/_mjs/stream.mjs.map +0 -1
package/_mjs/fs/api.mjs
CHANGED
|
@@ -1,311 +1,307 @@
|
|
|
1
|
-
|
|
2
|
-
import * as tsplus_module_1 from "@fncts/base/data/Newtype";
|
|
1
|
+
import * as tsplus_module_21 from "@fncts/io/Queue/constructors";
|
|
3
2
|
import * as tsplus_module_2 from "@fncts/io/IO/api";
|
|
3
|
+
import * as tsplus_module_19 from "@fncts/io/Queue/api/operations";
|
|
4
|
+
import * as tsplus_module_11 from "@fncts/io/Channel/api";
|
|
5
|
+
import * as tsplus_module_10 from "@fncts/base/data/Maybe/definition";
|
|
6
|
+
import * as tsplus_module_16 from "@fncts/base/data/Either/constructors";
|
|
7
|
+
import * as tsplus_module_20 from "@fncts/io/IO/runtime";
|
|
8
|
+
import * as tsplus_module_12 from "@fncts/io/Channel/core-api";
|
|
9
|
+
import * as tsplus_module_18 from "@fncts/base/collection/immutable/Conc/api";
|
|
10
|
+
import * as tsplus_module_9 from "@fncts/io/Sink/definition";
|
|
11
|
+
import * as tsplus_module_15 from "@fncts/io/IO/api/acquireRelease";
|
|
12
|
+
import * as tsplus_module_7 from "@fncts/io/Stream/api";
|
|
4
13
|
import * as tsplus_module_3 from "@fncts/base/collection/immutable/Conc/constructors";
|
|
5
|
-
import * as tsplus_module_4 from "@fncts/io/Ref/api/set";
|
|
6
14
|
import * as tsplus_module_5 from "@fncts/base/data/Maybe/constructors";
|
|
15
|
+
import * as tsplus_module_1 from "@fncts/base/data/Newtype";
|
|
16
|
+
import * as tsplus_module_4 from "@fncts/io/Ref/api/set";
|
|
7
17
|
import * as tsplus_module_6 from "@fncts/io/Ref/api/get";
|
|
8
|
-
import * as tsplus_module_7 from "@fncts/io/Stream/api";
|
|
9
18
|
import * as tsplus_module_8 from "@fncts/io/Ref/constructors";
|
|
10
|
-
import * as tsplus_module_9 from "@fncts/io/Sink/definition";
|
|
11
|
-
import * as tsplus_module_10 from "@fncts/base/data/Maybe/definition";
|
|
12
|
-
import * as tsplus_module_11 from "@fncts/io/Channel/api";
|
|
13
|
-
import * as tsplus_module_12 from "@fncts/io/Channel/core-api";
|
|
14
19
|
import * as tsplus_module_13 from "@fncts/base/data/Cause/api";
|
|
15
20
|
import * as tsplus_module_14 from "@fncts/io/Ref/api/modify";
|
|
16
|
-
import * as tsplus_module_15 from "@fncts/io/IO/api/acquireRelease";
|
|
17
|
-
import * as tsplus_module_16 from "@fncts/base/data/Either/constructors";
|
|
18
21
|
import * as tsplus_module_17 from "@fncts/io/IO/api/asyncInterrupt";
|
|
19
|
-
import * as tsplus_module_18 from "@fncts/base/collection/immutable/Conc/api";
|
|
20
|
-
import * as tsplus_module_19 from "@fncts/io/Queue/api/operations";
|
|
21
|
-
import * as tsplus_module_20 from "@fncts/io/IO/runtime";
|
|
22
|
-
import * as tsplus_module_21 from "@fncts/io/Queue/constructors";
|
|
23
22
|
import * as fs from "fs";
|
|
24
|
-
|
|
23
|
+
//#region build/esm/fs/api.js
|
|
24
|
+
const fileName_1 = "(@fncts/node) src/fs/api.ts";
|
|
25
|
+
const FileDescriptor = tsplus_module_1.newtype();
|
|
25
26
|
function unitErrorCallback(cb) {
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
runtime.unsafeRunFiber(tsplus_module_19.offer([curr, prev], fileName_1 + ":574:43")(queue), fileName_1 + ":574:31");
|
|
307
|
-
});
|
|
308
|
-
return queue;
|
|
309
|
-
}, fileName_1 + ":572:24")(tsplus_module_20.runtime(fileName_1 + ":572:35")), fileName_1 + ":571:24")(tsplus_module_21.makeUnbounded(fileName_1 + ":571:44")), queue => tsplus_module_19.shutdown(queue, fileName_1 + ":578:21"), fileName_1 + ":569:31"));
|
|
310
|
-
}
|
|
27
|
+
return (err) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":17:36")) : cb(tsplus_module_2.unit);
|
|
28
|
+
}
|
|
29
|
+
function access(path, mode) {
|
|
30
|
+
return tsplus_module_2.async((cb) => {
|
|
31
|
+
fs.access(path, mode, (err) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":22:53")) : cb(tsplus_module_2.unit));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function appendFile(path, data, options) {
|
|
35
|
+
return tsplus_module_2.async((cb) => {
|
|
36
|
+
fs.appendFile(path, data, options ?? {}, (err) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":32:79")) : cb(tsplus_module_2.unit));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function chmod(path, mode) {
|
|
40
|
+
return tsplus_module_2.async((cb) => {
|
|
41
|
+
fs.chmod(path, mode, (err) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":38:52")) : cb(tsplus_module_2.unit));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function close(fd) {
|
|
45
|
+
return tsplus_module_2.async((cb) => {
|
|
46
|
+
fs.close(FileDescriptor.reverseGet(fd), (err) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":44:71")) : cb(tsplus_module_2.unit));
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function chown(path, uid, gid) {
|
|
50
|
+
return tsplus_module_2.async((cb) => {
|
|
51
|
+
fs.chown(path, uid, gid, (err) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":50:56")) : cb(tsplus_module_2.unit));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function copyFile(src, dest, flags) {
|
|
55
|
+
return tsplus_module_2.async((cb) => {
|
|
56
|
+
fs.copyFile(src, dest, flags, (err) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":56:61")) : cb(tsplus_module_2.unit));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function createReadStream(path, options) {
|
|
60
|
+
const chunkSize = options?.chunkSize ?? 1024 * 64;
|
|
61
|
+
return tsplus_module_7.flatMap(([fd, state]) => tsplus_module_7.repeatIOChunkMaybe(tsplus_module_2.flatMap(([pos, end]) => {
|
|
62
|
+
const n = Math.min(end - pos + 1, chunkSize);
|
|
63
|
+
return tsplus_module_2.flatMap(([bytes, chunk]) => tsplus_module_2.flatMap(() => tsplus_module_2.map(() => {
|
|
64
|
+
if (bytes !== chunk.length) {
|
|
65
|
+
const dst = Buffer.allocUnsafeSlow(bytes);
|
|
66
|
+
chunk.copy(dst, 0, 0, bytes);
|
|
67
|
+
return tsplus_module_3.fromBuffer(dst);
|
|
68
|
+
} else return tsplus_module_3.fromBuffer(chunk);
|
|
69
|
+
}, fileName_1 + ":94:10")(tsplus_module_4.set([pos + n, end], fileName_1 + ":94:20")(state)), fileName_1 + ":93:10")(tsplus_module_2.when(() => bytes === 0, fileName_1 + ":93:34")(tsplus_module_2.fail(() => tsplus_module_5.nothing(fileName_1 + ":93:26"), fileName_1 + ":93:18"))), fileName_1 + ":91:33")(tsplus_module_2.mapError(tsplus_module_5.just, fileName_1 + ":91:59")(read(fd, n, pos)));
|
|
70
|
+
}, fileName_1 + ":89:33")(tsplus_module_6.get(state, fileName_1 + ":89:39")), fileName_1 + ":87:30"), fileName_1 + ":86:12")(tsplus_module_7.acquireRelease(tsplus_module_2.zip(tsplus_module_2.defer(() => {
|
|
71
|
+
const start = options?.start ?? 0;
|
|
72
|
+
const end = options?.end ?? Infinity;
|
|
73
|
+
if (end < start) return tsplus_module_2.fail(() => /* @__PURE__ */ new RangeError(`start (${start}) must be <= end (${end})`), fileName_1 + ":79:25");
|
|
74
|
+
else return tsplus_module_8.make(() => [start, end], fileName_1 + ":81:26");
|
|
75
|
+
}, fileName_1 + ":75:15"), fileName_1 + ":74:75")(open(path, options?.flags ?? fs.constants.O_RDONLY, options?.mode)), ([fd, _]) => tsplus_module_2.orHalt(close(fd), fileName_1 + ":85:27"), fileName_1 + ":73:31"));
|
|
76
|
+
}
|
|
77
|
+
function createWriteSink(path, options) {
|
|
78
|
+
return new tsplus_module_9.Sink(tsplus_module_11.unwrapScoped(() => tsplus_module_2.flatMap((errorRef) => tsplus_module_2.flatMap((st) => tsplus_module_2.map((maybeError) => {
|
|
79
|
+
if (!st && tsplus_module_10.isJust(maybeError)) return tsplus_module_11.readWith((_) => tsplus_module_12.zipRight(tsplus_module_12.end(() => void 0))(tsplus_module_11.fail(() => maybeError.value)), (err) => tsplus_module_12.failCause(() => tsplus_module_13.sequential(tsplus_module_13.fail(maybeError.value), tsplus_module_13.fail(err))), (_) => tsplus_module_11.fail(() => maybeError.value));
|
|
80
|
+
else {
|
|
81
|
+
const reader = tsplus_module_11.readWith((inp) => tsplus_module_11.unwrap(() => tsplus_module_2.map(() => reader, fileName_1 + ":151:23")(tsplus_module_2.flatMap(() => tsplus_module_14.update((n) => n !== void 0 ? n + inp.length : void 0, fileName_1 + ":150:47")(st[1]), fileName_1 + ":150:27")(tsplus_module_2.flatMap((pos) => write(st[0], inp, pos), fileName_1 + ":149:27")(tsplus_module_6.get(st[1], fileName_1 + ":148:23"))))), (err) => tsplus_module_11.fail(() => err), (_) => tsplus_module_12.end(() => void 0));
|
|
82
|
+
return reader;
|
|
83
|
+
}
|
|
84
|
+
}, fileName_1 + ":128:29")(tsplus_module_6.get(errorRef, fileName_1 + ":128:38")), fileName_1 + ":121:27")(tsplus_module_2.catchAll((err) => tsplus_module_4.set(tsplus_module_5.just(err, fileName_1 + ":125:49"), fileName_1 + ":125:44")(errorRef), fileName_1 + ":125:22")(tsplus_module_15.acquireRelease(() => tsplus_module_2.zip(tsplus_module_8.make(() => options?.start ?? void 0, fileName_1 + ":123:26"), fileName_1 + ":123:17")(open(path, options?.flags ?? fs.constants.O_CREAT | fs.constants.O_WRONLY, options?.mode)), ([fd, _]) => tsplus_module_2.orHalt(close(fd), fileName_1 + ":124:51"), fileName_1 + ":124:28"))), fileName_1 + ":120:27")(tsplus_module_8.make(() => tsplus_module_5.nothing(fileName_1 + ":120:67"), fileName_1 + ":120:36"))));
|
|
85
|
+
}
|
|
86
|
+
function fchmod(fd, mode) {
|
|
87
|
+
return tsplus_module_2.async((cb) => {
|
|
88
|
+
fs.fchmod(FileDescriptor.reverseGet(fd), mode, unitErrorCallback(cb));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function fchown(fd, uid, gid) {
|
|
92
|
+
return tsplus_module_2.async((cb) => {
|
|
93
|
+
fs.fchown(FileDescriptor.reverseGet(fd), uid, gid, unitErrorCallback(cb));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function fdatasync(fd) {
|
|
97
|
+
return tsplus_module_2.async((cb) => {
|
|
98
|
+
fs.fdatasync(FileDescriptor.reverseGet(fd), unitErrorCallback(cb));
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function fstat(fd) {
|
|
102
|
+
return tsplus_module_2.async((cb) => {
|
|
103
|
+
fs.fstat(FileDescriptor.reverseGet(fd), (err, stats) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":183:78")) : cb(tsplus_module_2.succeedNow(stats, fileName_1 + ":183:103")));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function fsync(fd) {
|
|
107
|
+
return tsplus_module_2.async((cb) => {
|
|
108
|
+
fs.fsync(FileDescriptor.reverseGet(fd), unitErrorCallback(cb));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function ftruncate(fd, len) {
|
|
112
|
+
return tsplus_module_2.async((cb) => {
|
|
113
|
+
fs.ftruncate(FileDescriptor.reverseGet(fd), len, unitErrorCallback(cb));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function futimes(fd, atime, mtime) {
|
|
117
|
+
return tsplus_module_2.async((cb) => {
|
|
118
|
+
fs.futimes(FileDescriptor.reverseGet(fd), atime, mtime, unitErrorCallback(cb));
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function lchmod(path, mode) {
|
|
122
|
+
return tsplus_module_2.async((cb) => {
|
|
123
|
+
fs.lchmod(path, mode, unitErrorCallback(cb));
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function lchown(path, uid, gid) {
|
|
127
|
+
return tsplus_module_2.async((cb) => {
|
|
128
|
+
fs.lchown(path, uid, gid, unitErrorCallback(cb));
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function lutimes(path, atime, mtime) {
|
|
132
|
+
return tsplus_module_2.async((cb) => {
|
|
133
|
+
fs.lutimes(path, atime, mtime, unitErrorCallback(cb));
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function link(path, newPath) {
|
|
137
|
+
return tsplus_module_2.async((cb) => {
|
|
138
|
+
fs.link(path, newPath, (err) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":233:54")) : cb(tsplus_module_2.unit));
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function lstat(path) {
|
|
142
|
+
return tsplus_module_2.async((cb) => {
|
|
143
|
+
fs.lstat(path, (err, stats) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":239:53")) : cb(tsplus_module_2.succeedNow(stats, fileName_1 + ":239:78")));
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function mkdir(path, options) {
|
|
147
|
+
return tsplus_module_2.async((cb) => {
|
|
148
|
+
fs.mkdir(path, options, (err, path) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":248:61")) : cb(tsplus_module_2.succeed(() => tsplus_module_5.fromNullable(path), fileName_1 + ":248:83")));
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function mkdtemp(prefix, options) {
|
|
152
|
+
return tsplus_module_2.async((cb) => {
|
|
153
|
+
fs.mkdtemp(prefix, options, (err, folder) => err ? cb(tsplus_module_2.failNow(err, fileName_1 + ":254:70")) : cb(tsplus_module_2.succeedNow(folder, fileName_1 + ":254:95")));
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function open(path, flags, mode) {
|
|
157
|
+
return tsplus_module_2.async((cb) => {
|
|
158
|
+
fs.open(path, flags, mode ?? null, (err, fd) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":264:70")) : cb(tsplus_module_2.succeed(() => FileDescriptor.get(fd), fileName_1 + ":264:92")));
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
var Dir = class {
|
|
162
|
+
path;
|
|
163
|
+
_dir;
|
|
164
|
+
constructor(dir) {
|
|
165
|
+
this.path = dir.path;
|
|
166
|
+
this._dir = dir;
|
|
167
|
+
}
|
|
168
|
+
close() {
|
|
169
|
+
return tsplus_module_2.async((cb) => {
|
|
170
|
+
this._dir.close(unitErrorCallback(cb));
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
read() {
|
|
174
|
+
return tsplus_module_2.async((cb) => {
|
|
175
|
+
this._dir.read((err, dirEnt) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":284:56")) : cb(tsplus_module_2.succeedNow(tsplus_module_5.fromNullable(dirEnt), fileName_1 + ":284:81")));
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
function opendir(path, options) {
|
|
180
|
+
return tsplus_module_2.async((cb) => {
|
|
181
|
+
fs.opendir(path, options ?? {}, (err, dir) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":291:75")) : cb(tsplus_module_2.succeedNow(new Dir(dir), fileName_1 + ":291:100")));
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function read(fd, length, position) {
|
|
185
|
+
return tsplus_module_2.async((cb) => {
|
|
186
|
+
const buf = Buffer.alloc(length);
|
|
187
|
+
fs.read(FileDescriptor.reverseGet(fd), buf, 0, length, position ?? null, (err, bytesRead, buffer) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":303:23")) : cb(tsplus_module_2.succeed(() => [bytesRead, buffer], fileName_1 + ":303:45")));
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function readFile(file, options = {}) {
|
|
191
|
+
return tsplus_module_17.asyncInterrupt((cb) => {
|
|
192
|
+
const abortController = new AbortController();
|
|
193
|
+
fs.readFile(file, {
|
|
194
|
+
...options,
|
|
195
|
+
signal: abortController.signal
|
|
196
|
+
}, (err, data) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":320:23")) : cb(tsplus_module_2.succeedNow(data, fileName_1 + ":320:48")));
|
|
197
|
+
return tsplus_module_16.left(tsplus_module_2.succeed(() => abortController.abort(), fileName_1 + ":322:34"), fileName_1 + ":322:23");
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function readdir(path, options) {
|
|
201
|
+
return tsplus_module_2.async((cb) => {
|
|
202
|
+
fs.readdir(path, options ?? {}, (err, files) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":356:23")) : files[0] && files[0] instanceof fs.Dir ? files.map((a) => new Dir(a)) : files);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function realpath(path, options) {
|
|
206
|
+
return tsplus_module_2.async((cb) => {
|
|
207
|
+
fs.realpath(path, options ?? {}, (err, resolvedPath) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":375:78")) : cb(tsplus_module_2.succeedNow(resolvedPath, fileName_1 + ":375:103")));
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
function realpathNative(path, options) {
|
|
211
|
+
return tsplus_module_2.async((cb) => {
|
|
212
|
+
fs.realpath.native(path, options ?? {}, (err, resolvedPath) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":394:23")) : cb(tsplus_module_2.succeed(() => resolvedPath, fileName_1 + ":394:45")));
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function rename(oldPath, newPath) {
|
|
216
|
+
return tsplus_module_2.async((cb) => {
|
|
217
|
+
fs.rename(oldPath, newPath, unitErrorCallback(cb));
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function rm(path, options) {
|
|
221
|
+
return tsplus_module_2.async((cb) => {
|
|
222
|
+
fs.rm(path, options ?? {}, unitErrorCallback(cb));
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function rmdir(path) {
|
|
226
|
+
return tsplus_module_2.async((cb) => {
|
|
227
|
+
fs.rmdir(path, unitErrorCallback(cb));
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function stat(path, options) {
|
|
231
|
+
return tsplus_module_2.async((cb) => {
|
|
232
|
+
fs.stat(path, options ?? {}, (err, stats) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":424:76")) : cb(tsplus_module_2.succeedNow(stats, fileName_1 + ":424:101")));
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function symlink(target, path) {
|
|
236
|
+
return tsplus_module_2.async((cb) => {
|
|
237
|
+
fs.symlink(target, path, unitErrorCallback(cb));
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
function truncate(path, len) {
|
|
241
|
+
return tsplus_module_2.async((cb) => {
|
|
242
|
+
fs.truncate(path, len, unitErrorCallback(cb));
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function unlink(path) {
|
|
246
|
+
return tsplus_module_2.async((cb) => {
|
|
247
|
+
fs.unlink(path, unitErrorCallback(cb));
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
function utimes(path, atime, mtime) {
|
|
251
|
+
return tsplus_module_2.async((cb) => {
|
|
252
|
+
fs.utimes(path, atime, mtime, unitErrorCallback(cb));
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
function write(fd, buffer, position) {
|
|
256
|
+
return tsplus_module_2.async((cb) => {
|
|
257
|
+
const b = tsplus_module_18.toBuffer(buffer);
|
|
258
|
+
fs.write(FileDescriptor.reverseGet(fd), b, position ?? null, b.byteLength, (err, bytesWritten) => err ? cb(tsplus_module_2.failNow(err, fileName_1 + ":460:26")) : cb(tsplus_module_2.succeedNow(bytesWritten, fileName_1 + ":460:51")));
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function writeFile(file, data, options = {}) {
|
|
262
|
+
return tsplus_module_17.asyncInterrupt((cb) => {
|
|
263
|
+
const abortController = new AbortController();
|
|
264
|
+
fs.writeFile(file, data, {
|
|
265
|
+
...options,
|
|
266
|
+
signal: abortController.signal
|
|
267
|
+
}, (err) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":479:23")) : tsplus_module_2.unit);
|
|
268
|
+
return tsplus_module_16.left(tsplus_module_2.succeed(() => abortController.abort(), fileName_1 + ":481:34"), fileName_1 + ":481:23");
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
function writev(fd, buffers, position) {
|
|
272
|
+
return tsplus_module_2.async((cb) => {
|
|
273
|
+
if (position) fs.writev(FileDescriptor.reverseGet(fd), buffers, position, (err, bytesWritten) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":493:25")) : cb(tsplus_module_2.succeedNow(bytesWritten, fileName_1 + ":493:50")));
|
|
274
|
+
else fs.writev(FileDescriptor.reverseGet(fd), buffers, (err, bytesWritten) => err ? cb(tsplus_module_2.fail(() => err, fileName_1 + ":497:25")) : cb(tsplus_module_2.succeedNow(bytesWritten, fileName_1 + ":497:50")));
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
function watch(filename, options) {
|
|
278
|
+
return tsplus_module_7.flatMap((watcher) => tsplus_module_7.repeatIOMaybe(tsplus_module_2.async((cb) => {
|
|
279
|
+
watcher.once("change", (eventType, filename) => {
|
|
280
|
+
watcher.removeAllListeners();
|
|
281
|
+
cb(tsplus_module_2.succeedNow({
|
|
282
|
+
eventType,
|
|
283
|
+
filename
|
|
284
|
+
}, fileName_1 + ":533:27"));
|
|
285
|
+
});
|
|
286
|
+
watcher.once("error", (error) => {
|
|
287
|
+
watcher.removeAllListeners();
|
|
288
|
+
cb(tsplus_module_2.failNow(tsplus_module_5.just(error, fileName_1 + ":537:29"), fileName_1 + ":537:24"));
|
|
289
|
+
});
|
|
290
|
+
watcher.once("close", () => {
|
|
291
|
+
watcher.removeAllListeners();
|
|
292
|
+
cb(tsplus_module_2.failNow(tsplus_module_5.nothing(fileName_1 + ":541:32"), fileName_1 + ":541:24"));
|
|
293
|
+
});
|
|
294
|
+
}), fileName_1 + ":529:25"), fileName_1 + ":528:12")(tsplus_module_7.fromIO(tsplus_module_2.tryCatch(() => fs.watch(filename, options ?? {}), (err) => err, fileName_1 + ":524:16"), fileName_1 + ":523:23"));
|
|
295
|
+
}
|
|
296
|
+
function watchFile(filename, options) {
|
|
297
|
+
return tsplus_module_7.flatMap((queue) => tsplus_module_7.repeatIOMaybe(tsplus_module_19.take(queue, fileName_1 + ":578:50"), fileName_1 + ":578:44"), fileName_1 + ":578:12")(tsplus_module_7.acquireRelease(tsplus_module_2.flatMap((queue) => tsplus_module_2.map((runtime) => {
|
|
298
|
+
fs.watchFile(filename, options ?? {}, (curr, prev) => {
|
|
299
|
+
runtime.unsafeRunFiber(tsplus_module_19.offer([curr, prev], fileName_1 + ":573:43")(queue), fileName_1 + ":573:31");
|
|
300
|
+
});
|
|
301
|
+
return queue;
|
|
302
|
+
}, fileName_1 + ":571:24")(tsplus_module_20.runtime(fileName_1 + ":571:35")), fileName_1 + ":570:24")(tsplus_module_21.makeUnbounded(fileName_1 + ":570:44")), (queue) => tsplus_module_19.shutdown(queue, fileName_1 + ":577:21"), fileName_1 + ":568:31"));
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
305
|
+
export { Dir, FileDescriptor, access, appendFile, chmod, chown, close, copyFile, createReadStream, createWriteSink, fchmod, fchown, fdatasync, fstat, fsync, ftruncate, futimes, lchmod, lchown, link, lstat, lutimes, mkdir, mkdtemp, open, opendir, read, readFile, readdir, realpath, realpathNative, rename, rm, rmdir, stat, symlink, truncate, unlink, utimes, watch, watchFile, write, writeFile, writev };
|
|
306
|
+
|
|
311
307
|
//# sourceMappingURL=api.mjs.map
|