@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/stream/api.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const fileName_1 = "(@fncts/node) src/stream/api.ts";
|
|
2
1
|
import * as tsplus_module_1 from "@fncts/io/Queue/constructors";
|
|
3
2
|
import * as tsplus_module_2 from "@fncts/io/IO/api";
|
|
4
3
|
import * as tsplus_module_3 from "@fncts/io/Queue/api/operations";
|
|
@@ -24,210 +23,188 @@ import * as tsplus_module_22 from "@fncts/base/collection/immutable/Conc/constru
|
|
|
24
23
|
import * as tsplus_module_23 from "@fncts/base/data/Maybe/constructors";
|
|
25
24
|
import * as tsplus_module_24 from "@fncts/io/IO/api/scoped";
|
|
26
25
|
import { Stream } from "@fncts/io/Stream";
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
//#region build/esm/stream/api.js
|
|
27
|
+
const fileName_1 = "(@fncts/node) src/stream/api.ts";
|
|
28
|
+
var ReadableError = class {
|
|
29
|
+
error;
|
|
30
|
+
_tag = "ReadableError";
|
|
31
|
+
constructor(error) {
|
|
32
|
+
this.error = error;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function fromReadable(readable, onError, chunkSize) {
|
|
36
|
+
return new Stream(fromReadableChannel(readable, onError, chunkSize));
|
|
35
37
|
}
|
|
36
38
|
function fromReadableChannel(evaluate, onError, chunkSize) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
}, fileName_1 + ":30:9")));
|
|
39
|
+
return tsplus_module_4.acquireReleaseWith(tsplus_module_2.tap(([readable, queue]) => readableOffer(readable, queue, onError), fileName_1 + ":27:11")(tsplus_module_2.zip(tsplus_module_1.makeUnbounded(fileName_1 + ":26:31"), fileName_1 + ":26:11")(tsplus_module_2.succeed(evaluate, fileName_1 + ":25:7"))), ([readable, queue]) => readableTake(readable, queue, chunkSize), ([readable, queue]) => tsplus_module_2.zipRight(tsplus_module_3.shutdown(queue, fileName_1 + ":36:17"), fileName_1 + ":36:11")(tsplus_module_2.succeed(() => {
|
|
40
|
+
readable.removeAllListeners();
|
|
41
|
+
if ("closed" in readable && !readable.closed) readable.destroy();
|
|
42
|
+
}, fileName_1 + ":30:9")));
|
|
43
43
|
}
|
|
44
44
|
function readableOffer(readable, queue, onError) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (readable.readable) {
|
|
59
|
-
tsplus_module_3.unsafeOffer(tsplus_module_6.right(void 0, fileName_1 + ":58:37"), fileName_1 + ":58:24")(queue);
|
|
60
|
-
}
|
|
61
|
-
}, fileName_1 + ":44:12");
|
|
45
|
+
return tsplus_module_2.succeed(() => {
|
|
46
|
+
readable.on("readable", () => {
|
|
47
|
+
const size = tsplus_module_3.unsafeSize(queue, fileName_1 + ":48:25");
|
|
48
|
+
if (tsplus_module_5.isJust(size) && size.value <= 0) tsplus_module_7.unsafeRun(tsplus_module_3.offer(tsplus_module_6.right(void 0, fileName_1 + ":50:33"), fileName_1 + ":50:20")(queue));
|
|
49
|
+
});
|
|
50
|
+
readable.on("error", (err) => {
|
|
51
|
+
tsplus_module_3.unsafeOffer(tsplus_module_6.left(tsplus_module_8.fail(onError(err), fileName_1 + ":55:46"), fileName_1 + ":55:36"), fileName_1 + ":55:24")(queue);
|
|
52
|
+
});
|
|
53
|
+
readable.on("end", () => {
|
|
54
|
+
tsplus_module_3.unsafeOffer(tsplus_module_6.left(tsplus_module_8.unit, fileName_1 + ":59:36"), fileName_1 + ":59:24")(queue);
|
|
55
|
+
});
|
|
56
|
+
if (readable.readable) tsplus_module_3.unsafeOffer(tsplus_module_6.right(void 0, fileName_1 + ":62:37"), fileName_1 + ":62:24")(queue);
|
|
57
|
+
}, fileName_1 + ":45:12");
|
|
62
58
|
}
|
|
63
59
|
function readableTake(readable, queue, chunkSize) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
const read = readChunkChannel(readable, chunkSize);
|
|
61
|
+
const loop = tsplus_module_9.flatMap((either) => tsplus_module_11.match((exit) => tsplus_module_10.match((cause) => tsplus_module_9.failCauseNow(cause), () => tsplus_module_4.unit)(exit), () => tsplus_module_9.flatMap(() => loop)(read))(either))(tsplus_module_4.fromIO(() => tsplus_module_3.take(queue, fileName_1 + ":73:100")));
|
|
62
|
+
return loop;
|
|
67
63
|
}
|
|
68
64
|
function readChunkChannel(readable, chunkSize) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
65
|
+
return tsplus_module_4.defer(() => {
|
|
66
|
+
const arr = [];
|
|
67
|
+
let chunk = readable.read(chunkSize);
|
|
68
|
+
while (chunk !== null) {
|
|
69
|
+
arr.push(chunk);
|
|
70
|
+
chunk = readable.read(chunkSize);
|
|
71
|
+
}
|
|
72
|
+
return tsplus_module_4.write(() => tsplus_module_12.fromArray(arr));
|
|
73
|
+
});
|
|
78
74
|
}
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
function fromWritable(writable, onError, options) {
|
|
76
|
+
return tsplus_module_13.fromChannel(fromWritableChannel(writable, onError, options), fileName_1 + ":109:26");
|
|
81
77
|
}
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
function fromWritableChannel(writable, onError, options) {
|
|
79
|
+
return tsplus_module_9.flatMap(([writable, future]) => tsplus_module_4.embedInput(writeInput(writable, (cause) => tsplus_module_14.failCause(cause, fileName_1 + ":119:62")(future), options, tsplus_module_14.fulfill(tsplus_module_2.unit, fileName_1 + ":119:94")(future)))(writableOutput(writable, future, onError)))(tsplus_module_4.fromIO(() => tsplus_module_2.zip(tsplus_module_15.make(fileName_1 + ":117:53"), fileName_1 + ":117:41")(tsplus_module_2.succeed(writable, fileName_1 + ":117:27"))));
|
|
84
80
|
}
|
|
85
|
-
function writeInput(writable, onFailure, {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
awaitRead: tsplus_module_2.unit,
|
|
99
|
-
emit: write,
|
|
100
|
-
error: cause => tsplus_module_2.zipRight(onFailure(cause), fileName_1 + ":140:30")(close),
|
|
101
|
-
done: _ => tsplus_module_2.zipRight(onDone, fileName_1 + ":141:25")(close)
|
|
102
|
-
};
|
|
81
|
+
function writeInput(writable, onFailure, { encoding, endOnDone = true } = {}, onDone = tsplus_module_2.unit) {
|
|
82
|
+
const write = writeIO(writable, encoding);
|
|
83
|
+
const close = endOnDone ? tsplus_module_2.async((resume) => {
|
|
84
|
+
if ("closed" in writable && writable.closed) resume(tsplus_module_2.unit);
|
|
85
|
+
else writable.once("finish", () => resume(tsplus_module_2.unit));
|
|
86
|
+
}) : tsplus_module_2.unit;
|
|
87
|
+
return {
|
|
88
|
+
awaitRead: tsplus_module_2.unit,
|
|
89
|
+
emit: write,
|
|
90
|
+
error: (cause) => tsplus_module_2.zipRight(onFailure(cause), fileName_1 + ":145:30")(close),
|
|
91
|
+
done: (_) => tsplus_module_2.zipRight(onDone, fileName_1 + ":146:25")(close)
|
|
92
|
+
};
|
|
103
93
|
}
|
|
104
94
|
function writeIO(writable, encoding) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
} else {
|
|
128
|
-
return tsplus_module_2.unit;
|
|
129
|
-
}
|
|
130
|
-
}, () => {
|
|
131
|
-
next = iterator.next();
|
|
132
|
-
});
|
|
133
|
-
}, fileName_1 + ":150:24");
|
|
134
|
-
}
|
|
135
|
-
};
|
|
95
|
+
return (chunk) => {
|
|
96
|
+
if (chunk.length === 0) return tsplus_module_2.unit;
|
|
97
|
+
else return tsplus_module_16.asyncIO((resume) => {
|
|
98
|
+
const iterator = chunk[Symbol.iterator]();
|
|
99
|
+
let done = false;
|
|
100
|
+
let next = iterator.next();
|
|
101
|
+
return tsplus_module_2.whileLoop(() => !done, () => {
|
|
102
|
+
if (next.done) return tsplus_module_2.succeed(() => {
|
|
103
|
+
done = true;
|
|
104
|
+
resume(tsplus_module_2.unit);
|
|
105
|
+
}, fileName_1 + ":165:24");
|
|
106
|
+
if (!writable.write(next.value, encoding)) return tsplus_module_2.async((k) => {
|
|
107
|
+
writable.once("drain", () => {
|
|
108
|
+
k(tsplus_module_2.unit);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
else return tsplus_module_2.unit;
|
|
112
|
+
}, () => {
|
|
113
|
+
next = iterator.next();
|
|
114
|
+
});
|
|
115
|
+
}, fileName_1 + ":155:24");
|
|
116
|
+
};
|
|
136
117
|
}
|
|
137
118
|
function writableOutput(writable, future, onError) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
export class TransformError {
|
|
147
|
-
constructor(error) {
|
|
148
|
-
this.error = error;
|
|
149
|
-
this._tag = "TransformError";
|
|
150
|
-
}
|
|
119
|
+
return tsplus_module_4.fromIO(() => tsplus_module_2.defer(() => {
|
|
120
|
+
function handleError(err) {
|
|
121
|
+
tsplus_module_14.unsafeDone(tsplus_module_2.failNow(onError(err), fileName_1 + ":201:37"), fileName_1 + ":201:26")(future);
|
|
122
|
+
}
|
|
123
|
+
writable.on("error", handleError);
|
|
124
|
+
return tsplus_module_17.ensuring(tsplus_module_2.succeed(writable.removeListener("error", handleError), fileName_1 + ":206:38"), fileName_1 + ":206:35")(tsplus_module_14.wait(future, fileName_1 + ":206:20"));
|
|
125
|
+
}, fileName_1 + ":199:13"));
|
|
151
126
|
}
|
|
127
|
+
var TransformError = class {
|
|
128
|
+
error;
|
|
129
|
+
_tag = "TransformError";
|
|
130
|
+
constructor(error) {
|
|
131
|
+
this.error = error;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
152
134
|
/**
|
|
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
|
-
|
|
135
|
+
* @tsplus pipeable fncts.io.Stream transform
|
|
136
|
+
*/
|
|
137
|
+
function transform(transform) {
|
|
138
|
+
return (self) => {
|
|
139
|
+
const scopedSink = tsplus_module_2.map((transform) => {
|
|
140
|
+
const endTransform = tsplus_module_2.succeed(() => transform.end(), fileName_1 + ":224:40");
|
|
141
|
+
const reader = tsplus_module_4.readWith((inp) => tsplus_module_4.unwrap(() => tsplus_module_2.async((cb) => {
|
|
142
|
+
transform.write(tsplus_module_18.toBuffer(inp), (err) => {
|
|
143
|
+
err ? cb(tsplus_module_2.failNow(new TransformError(err), fileName_1 + ":230:38")) : tsplus_module_2.succeedNow(reader, fileName_1 + ":230:80");
|
|
144
|
+
});
|
|
145
|
+
})), (err) => tsplus_module_4.unwrap(() => tsplus_module_2.map(() => tsplus_module_4.failNow(err), fileName_1 + ":234:51")(endTransform)), () => tsplus_module_4.unwrap(() => tsplus_module_2.map(() => tsplus_module_4.unit, fileName_1 + ":235:48")(endTransform)));
|
|
146
|
+
return [transform, new tsplus_module_19.Sink(reader)];
|
|
147
|
+
}, fileName_1 + ":223:11")(tsplus_module_20.acquireRelease(() => tsplus_module_2.succeed(transform, fileName_1 + ":221:34"), (transform) => tsplus_module_2.succeed(() => transform.destroy(), fileName_1 + ":222:48"), fileName_1 + ":222:22"));
|
|
148
|
+
return tsplus_module_21.flatMap(([transform, sink]) => tsplus_module_21.ensuring(tsplus_module_2.succeed(() => transform.removeAllListeners(), fileName_1 + ":252:20"), fileName_1 + ":252:17")(tsplus_module_21.asyncIO((cb) => tsplus_module_2.zipRight(tsplus_module_21.run(sink, fileName_1 + ":251:29")(self), fileName_1 + ":251:20")(tsplus_module_2.succeed(() => {
|
|
149
|
+
transform.on("data", (chunk) => {
|
|
150
|
+
cb(tsplus_module_2.succeed(() => tsplus_module_22.fromBuffer(chunk), fileName_1 + ":243:26"));
|
|
151
|
+
});
|
|
152
|
+
transform.on("error", (err) => {
|
|
153
|
+
cb(tsplus_module_2.failNow(tsplus_module_23.just(new TransformError(err), fileName_1 + ":246:31"), fileName_1 + ":246:26"));
|
|
154
|
+
});
|
|
155
|
+
transform.on("end", () => {
|
|
156
|
+
cb(tsplus_module_2.failNow(tsplus_module_23.nothing(fileName_1 + ":249:34"), fileName_1 + ":249:26"));
|
|
157
|
+
});
|
|
158
|
+
}, fileName_1 + ":241:19")))), fileName_1 + ":239:45")(tsplus_module_21.scoped(() => scopedSink, fileName_1 + ":239:25"));
|
|
159
|
+
};
|
|
178
160
|
}
|
|
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
|
-
if ("closed" in stream && !stream.closed) {
|
|
204
|
-
stream.destroy();
|
|
205
|
-
}
|
|
206
|
-
}, fileName_1 + ":264:9"), fileName_1 + ":263:20")), fileName_1 + ":289:6");
|
|
161
|
+
function toString(readable, onFailure, options) {
|
|
162
|
+
const maxBytes = options?.maxBytes ? Number(options.maxBytes) : void 0;
|
|
163
|
+
return tsplus_module_24.scoped(tsplus_module_2.flatMap((stream) => tsplus_module_2.async((resume) => {
|
|
164
|
+
let string = "";
|
|
165
|
+
let bytes = 0;
|
|
166
|
+
stream.once("error", (err) => {
|
|
167
|
+
resume(tsplus_module_2.failNow(onFailure(err), fileName_1 + ":286:28"));
|
|
168
|
+
});
|
|
169
|
+
stream.once("end", () => {
|
|
170
|
+
resume(tsplus_module_2.succeedNow(string, fileName_1 + ":290:31"));
|
|
171
|
+
});
|
|
172
|
+
stream.on("data", (chunk) => {
|
|
173
|
+
string += chunk;
|
|
174
|
+
bytes += Buffer.byteLength(chunk);
|
|
175
|
+
if (maxBytes && bytes > maxBytes) resume(tsplus_module_2.failNow(onFailure(/* @__PURE__ */ new Error("maxBytes exceeded")), fileName_1 + ":297:30"));
|
|
176
|
+
});
|
|
177
|
+
}), fileName_1 + ":280:13")(tsplus_module_20.acquireRelease(() => tsplus_module_2.succeed(() => {
|
|
178
|
+
const stream = readable();
|
|
179
|
+
stream.setEncoding(options?.encoding ?? "utf8");
|
|
180
|
+
return stream;
|
|
181
|
+
}, fileName_1 + ":266:12"), (stream) => tsplus_module_2.succeed(() => {
|
|
182
|
+
stream.removeAllListeners();
|
|
183
|
+
if ("closed" in stream && !stream.closed) stream.destroy();
|
|
184
|
+
}, fileName_1 + ":272:9"), fileName_1 + ":271:20")), fileName_1 + ":301:6");
|
|
207
185
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if ("closed" in stream && !stream.closed) {
|
|
229
|
-
stream.destroy();
|
|
230
|
-
}
|
|
231
|
-
}, fileName_1 + ":302:9"), fileName_1 + ":301:20")), fileName_1 + ":327:6");
|
|
186
|
+
function toUint8Array(readable, onFailure, options = {}) {
|
|
187
|
+
const maxBytes = options.maxBytes ? Number(options.maxBytes) : void 0;
|
|
188
|
+
return tsplus_module_24.scoped(tsplus_module_2.flatMap((stream) => tsplus_module_2.async((resume) => {
|
|
189
|
+
let buffer = Buffer.alloc(0);
|
|
190
|
+
let bytes = 0;
|
|
191
|
+
stream.once("error", (err) => {
|
|
192
|
+
resume(tsplus_module_2.failNow(onFailure(err), fileName_1 + ":328:28"));
|
|
193
|
+
});
|
|
194
|
+
stream.once("end", () => {
|
|
195
|
+
resume(tsplus_module_2.succeedNow(buffer, fileName_1 + ":332:31"));
|
|
196
|
+
});
|
|
197
|
+
stream.on("data", (chunk) => {
|
|
198
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
199
|
+
bytes += chunk.length;
|
|
200
|
+
if (maxBytes && bytes > maxBytes) resume(tsplus_module_2.failNow(onFailure(/* @__PURE__ */ new Error("maxBytes exceeded")), fileName_1 + ":339:30"));
|
|
201
|
+
});
|
|
202
|
+
}), fileName_1 + ":322:13")(tsplus_module_20.acquireRelease(() => tsplus_module_2.succeed(readable, fileName_1 + ":312:12"), (stream) => tsplus_module_2.succeed(() => {
|
|
203
|
+
stream.removeAllListeners();
|
|
204
|
+
if ("closed" in stream && !stream.closed) stream.destroy();
|
|
205
|
+
}, fileName_1 + ":314:9"), fileName_1 + ":313:20")), fileName_1 + ":343:6");
|
|
232
206
|
}
|
|
207
|
+
//#endregion
|
|
208
|
+
export { ReadableError, TransformError, fromReadable, fromWritable, fromWritableChannel, toString, toUint8Array, transform };
|
|
209
|
+
|
|
233
210
|
//# sourceMappingURL=api.mjs.map
|
package/_mjs/stream/api.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.mjs","names":["Stream","ReadableError","constructor","error","_tag","fromReadable","readable","onError","chunkSize","fromReadableChannel","evaluate","tsplus_module_4","acquireReleaseWith","tsplus_module_2","tap","queue","readableOffer","fileName_1","zip","tsplus_module_1","makeUnbounded","succeed","readableTake","zipRight","tsplus_module_3","shutdown","removeAllListeners","closed","destroy","on","size","unsafeSize","tsplus_module_5","isJust","value","tsplus_module_7","unsafeRun","offer","tsplus_module_6","right","err","unsafeOffer","left","tsplus_module_8","fail","unit","read","readChunkChannel","loop","tsplus_module_9","flatMap","either","tsplus_module_11","match","exit","tsplus_module_10","cause","failCauseNow","fromIO","take","defer","arr","chunk","push","write","tsplus_module_12","fromArray","fromWritable","writable","options","tsplus_module_13","fromChannel","fromWritableChannel","future","embedInput","writeInput","tsplus_module_14","failCause","fulfill","writableOutput","tsplus_module_15","make","onFailure","encoding","endOnDone","onDone","writeIO","close","async","resume","once","awaitRead","emit","done","_","length","tsplus_module_16","asyncIO","iterator","Symbol","next","whileLoop","success","k","handleError","unsafeDone","failNow","tsplus_module_17","ensuring","removeListener","wait","TransformError","transform","self","scopedSink","map","endTransform","end","reader","readWith","inp","unwrap","cb","tsplus_module_18","toBuffer","succeedNow","tsplus_module_19","Sink","tsplus_module_20","acquireRelease","tsplus_module_21","sink","run","tsplus_module_22","fromBuffer","tsplus_module_23","just","nothing","scoped","toString","maxBytes","Number","undefined","tsplus_module_24","stream","string","bytes","Buffer","byteLength","Error","setEncoding","toUint8Array","buffer","alloc","concat"],"sources":["../../_src/stream/api.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,MAAM,QAAQ,kBAAkB;AAEzC,OAAM,MAAOC,aAAa;EAExBC,YAAqBC,KAAY;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A6F,OAAA,CAAWxB,SAAS,CAAC,IAAImE,KAAK,CAAC,mBAAmB,CAAC,CAAC,EAAApI,UAAA,aAAC,CAAC;MAC/D;IACF,CAAC,CAAC;EACJ,CAAC,CAAC,EAAAA,UAAA,cA1BC+G,gBAAA,CAAAC,cAAA,OAAApH,eAAA,CAAAQ,OAAA,CAAGf,QAAQ,EAAAW,UAAA,aAAC,EACA+H,MAAM,IACrBnI,eAAA,CAAAQ,OAAA,CAAG,MAAK;IACN2H,MAAM,CAACtH,kBAAkB,EAAE;IAC3B,IAAI,QAAQ,IAAIsH,MAAM,IAAI,CAACA,MAAM,CAACrH,MAAM,EAAE;MACxCqH,MAAM,CAACpH,OAAO,EAAE;IAClB;EACF,CAAC,EAAAX,UAAA,YAAC,EAAAA,UAAA,aACH,CAmBA,EAAAA,UAAA;AACL","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"api.mjs","names":[],"sources":["../../esm/stream/api.js"],"sourcesContent":["const fileName_1 = \"(@fncts/node) src/stream/api.ts\";\nimport * as tsplus_module_1 from \"@fncts/io/Queue/constructors\";\nimport * as tsplus_module_2 from \"@fncts/io/IO/api\";\nimport * as tsplus_module_3 from \"@fncts/io/Queue/api/operations\";\nimport * as tsplus_module_4 from \"@fncts/io/Channel/api\";\nimport * as tsplus_module_5 from \"@fncts/base/data/Maybe/definition\";\nimport * as tsplus_module_6 from \"@fncts/base/data/Either/constructors\";\nimport * as tsplus_module_7 from \"@fncts/io/IO/runtime\";\nimport * as tsplus_module_8 from \"@fncts/base/data/Exit/constructors\";\nimport * as tsplus_module_9 from \"@fncts/io/Channel/core-api\";\nimport * as tsplus_module_10 from \"@fncts/base/data/Exit/api\";\nimport * as tsplus_module_11 from \"@fncts/base/data/Either/destructors\";\nimport * as tsplus_module_12 from \"@fncts/base/collection/immutable/Conc/definition\";\nimport * as tsplus_module_13 from \"@fncts/io/Sink/api\";\nimport * as tsplus_module_14 from \"@fncts/io/Future/api\";\nimport * as tsplus_module_15 from \"@fncts/io/Future/constructors\";\nimport * as tsplus_module_16 from \"@fncts/io/IO/api/asyncIO\";\nimport * as tsplus_module_17 from \"@fncts/io/IO/api/interrupt\";\nimport * as tsplus_module_18 from \"@fncts/base/collection/immutable/Conc/api\";\nimport * as tsplus_module_19 from \"@fncts/io/Sink/definition\";\nimport * as tsplus_module_20 from \"@fncts/io/IO/api/acquireRelease\";\nimport * as tsplus_module_21 from \"@fncts/io/Stream/api\";\nimport * as tsplus_module_22 from \"@fncts/base/collection/immutable/Conc/constructors\";\nimport * as tsplus_module_23 from \"@fncts/base/data/Maybe/constructors\";\nimport * as tsplus_module_24 from \"@fncts/io/IO/api/scoped\";\nimport { Stream } from \"@fncts/io/Stream\";\nexport class ReadableError {\n error;\n _tag = \"ReadableError\";\n constructor(error) {\n this.error = error;\n }\n}\nexport function fromReadable(readable, onError, chunkSize) {\n return new Stream(fromReadableChannel(readable, onError, chunkSize));\n}\nfunction fromReadableChannel(evaluate, onError, chunkSize) {\n return tsplus_module_4.acquireReleaseWith(tsplus_module_2.tap(([readable, queue]) => readableOffer(readable, queue, onError), fileName_1 + \":27:11\")(tsplus_module_2.zip(tsplus_module_1.makeUnbounded(fileName_1 + \":26:31\"), fileName_1 + \":26:11\")(tsplus_module_2.succeed(evaluate, fileName_1 + \":25:7\"))), ([readable, queue]) => readableTake(readable, queue, chunkSize), ([readable, queue]) => tsplus_module_2.zipRight(tsplus_module_3.shutdown(queue, fileName_1 + \":36:17\"), fileName_1 + \":36:11\")(tsplus_module_2.succeed(() => {\n // @ts-expect-error\n readable.removeAllListeners();\n if (\"closed\" in readable && !readable.closed) {\n readable.destroy();\n }\n }, fileName_1 + \":30:9\")));\n}\nfunction readableOffer(readable, queue, onError) {\n return tsplus_module_2.succeed(() => {\n // @ts-expect-error\n readable.on(\"readable\", () => {\n const size = tsplus_module_3.unsafeSize(queue, fileName_1 + \":48:25\");\n if (tsplus_module_5.isJust(size) && size.value <= 0) {\n tsplus_module_7.unsafeRun(tsplus_module_3.offer(tsplus_module_6.right(void 0, fileName_1 + \":50:33\"), fileName_1 + \":50:20\")(queue));\n }\n });\n // @ts-expect-error\n readable.on(\"error\", (err) => {\n tsplus_module_3.unsafeOffer(tsplus_module_6.left(tsplus_module_8.fail(onError(err), fileName_1 + \":55:46\"), fileName_1 + \":55:36\"), fileName_1 + \":55:24\")(queue);\n });\n // @ts-expect-error\n readable.on(\"end\", () => {\n tsplus_module_3.unsafeOffer(tsplus_module_6.left(tsplus_module_8.unit, fileName_1 + \":59:36\"), fileName_1 + \":59:24\")(queue);\n });\n if (readable.readable) {\n tsplus_module_3.unsafeOffer(tsplus_module_6.right(void 0, fileName_1 + \":62:37\"), fileName_1 + \":62:24\")(queue);\n }\n }, fileName_1 + \":45:12\");\n}\nfunction readableTake(readable, queue, chunkSize) {\n const read = readChunkChannel(readable, chunkSize);\n const loop = tsplus_module_9.flatMap((either) => tsplus_module_11.match((exit) => tsplus_module_10.match((cause) => tsplus_module_9.failCauseNow(cause), () => tsplus_module_4.unit)(exit), () => tsplus_module_9.flatMap(() => loop)(read))(either))(tsplus_module_4.fromIO(() => tsplus_module_3.take(queue, fileName_1 + \":73:100\")));\n return loop;\n}\nfunction readChunkChannel(readable, chunkSize) {\n return tsplus_module_4.defer(() => {\n const arr = [];\n let chunk = readable.read(chunkSize);\n while (chunk !== null) {\n arr.push(chunk);\n chunk = readable.read(chunkSize);\n }\n return tsplus_module_4.write(() => tsplus_module_12.fromArray(arr));\n });\n}\nexport function fromWritable(writable, onError, options) {\n return tsplus_module_13.fromChannel(fromWritableChannel(writable, onError, options), fileName_1 + \":109:26\");\n}\nexport function fromWritableChannel(writable, onError, options) {\n return tsplus_module_9.flatMap(([writable, future]) => tsplus_module_4.embedInput(writeInput(writable, (cause) => tsplus_module_14.failCause(cause, fileName_1 + \":119:62\")(future), options, tsplus_module_14.fulfill(tsplus_module_2.unit, fileName_1 + \":119:94\")(future)))(writableOutput(writable, future, onError)))(tsplus_module_4.fromIO(() => tsplus_module_2.zip(tsplus_module_15.make(fileName_1 + \":117:53\"), fileName_1 + \":117:41\")(tsplus_module_2.succeed(writable, fileName_1 + \":117:27\"))));\n}\nfunction writeInput(writable, onFailure, { encoding, endOnDone = true } = {}, onDone = tsplus_module_2.unit) {\n const write = writeIO(writable, encoding);\n const close = endOnDone\n ? tsplus_module_2.async((resume) => {\n if (\"closed\" in writable && writable.closed) {\n resume(tsplus_module_2.unit);\n }\n else {\n // @ts-expect-error\n writable.once(\"finish\", () => resume(tsplus_module_2.unit));\n }\n })\n : tsplus_module_2.unit;\n return {\n awaitRead: tsplus_module_2.unit,\n emit: write,\n error: (cause) => tsplus_module_2.zipRight(onFailure(cause), fileName_1 + \":145:30\")(close),\n done: (_) => tsplus_module_2.zipRight(onDone, fileName_1 + \":146:25\")(close),\n };\n}\nfunction writeIO(writable, encoding) {\n return (chunk) => {\n if (chunk.length === 0) {\n return tsplus_module_2.unit;\n }\n else {\n return tsplus_module_16.asyncIO((resume) => {\n const iterator = chunk[Symbol.iterator]();\n let done = false;\n let next = iterator.next();\n return tsplus_module_2.whileLoop(() => !done, () => {\n if (next.done) {\n return tsplus_module_2.succeed(() => {\n done = true;\n resume(tsplus_module_2.unit);\n }, fileName_1 + \":165:24\");\n }\n const success = writable.write(next.value, encoding);\n if (!success) {\n return tsplus_module_2.async((k) => {\n // @ts-expect-error\n writable.once(\"drain\", () => {\n k(tsplus_module_2.unit);\n });\n });\n }\n else {\n return tsplus_module_2.unit;\n }\n }, () => {\n next = iterator.next();\n });\n }, fileName_1 + \":155:24\");\n }\n };\n}\nfunction writableOutput(writable, future, onError) {\n return tsplus_module_4.fromIO(() => tsplus_module_2.defer(() => {\n function handleError(err) {\n tsplus_module_14.unsafeDone(tsplus_module_2.failNow(onError(err), fileName_1 + \":201:37\"), fileName_1 + \":201:26\")(future);\n }\n // @ts-expect-error\n writable.on(\"error\", handleError);\n // @ts-expect-error\n return tsplus_module_17.ensuring(tsplus_module_2.succeed(writable.removeListener(\"error\", handleError), fileName_1 + \":206:38\"), fileName_1 + \":206:35\")(tsplus_module_14.wait(future, fileName_1 + \":206:20\"));\n }, fileName_1 + \":199:13\"));\n}\nexport class TransformError {\n error;\n _tag = \"TransformError\";\n constructor(error) {\n this.error = error;\n }\n}\n/**\n * @tsplus pipeable fncts.io.Stream transform\n */\nexport function transform(transform) {\n return (self) => {\n const scopedSink = tsplus_module_2.map((transform) => {\n const endTransform = tsplus_module_2.succeed(() => transform.end(), fileName_1 + \":224:40\");\n const reader = tsplus_module_4.readWith((inp) => tsplus_module_4.unwrap(() => tsplus_module_2.async((cb) => {\n transform.write(tsplus_module_18.toBuffer(inp), (err) => {\n err ? cb(tsplus_module_2.failNow(new TransformError(err), fileName_1 + \":230:38\")) : tsplus_module_2.succeedNow(reader, fileName_1 + \":230:80\");\n });\n })), (err) => tsplus_module_4.unwrap(() => tsplus_module_2.map(() => tsplus_module_4.failNow(err), fileName_1 + \":234:51\")(endTransform)), () => tsplus_module_4.unwrap(() => tsplus_module_2.map(() => tsplus_module_4.unit, fileName_1 + \":235:48\")(endTransform)));\n return [transform, new tsplus_module_19.Sink(reader)];\n }, fileName_1 + \":223:11\")(tsplus_module_20.acquireRelease(() => tsplus_module_2.succeed(transform, fileName_1 + \":221:34\"), (transform) => tsplus_module_2.succeed(() => transform.destroy(), fileName_1 + \":222:48\"), fileName_1 + \":222:22\"));\n return tsplus_module_21.flatMap(([transform, sink]) => tsplus_module_21.ensuring(tsplus_module_2.succeed(() => transform.removeAllListeners(), fileName_1 + \":252:20\"), fileName_1 + \":252:17\")(tsplus_module_21.asyncIO((cb) => tsplus_module_2.zipRight(tsplus_module_21.run(sink, fileName_1 + \":251:29\")(self), fileName_1 + \":251:20\")(tsplus_module_2.succeed(() => {\n transform.on(\"data\", (chunk) => {\n cb(tsplus_module_2.succeed(() => tsplus_module_22.fromBuffer(chunk), fileName_1 + \":243:26\"));\n });\n transform.on(\"error\", (err) => {\n cb(tsplus_module_2.failNow(tsplus_module_23.just(new TransformError(err), fileName_1 + \":246:31\"), fileName_1 + \":246:26\"));\n });\n transform.on(\"end\", () => {\n cb(tsplus_module_2.failNow(tsplus_module_23.nothing(fileName_1 + \":249:34\"), fileName_1 + \":249:26\"));\n });\n }, fileName_1 + \":241:19\")))), fileName_1 + \":239:45\")(tsplus_module_21.scoped(() => scopedSink, fileName_1 + \":239:25\"));\n };\n}\nexport function toString(readable, onFailure, options) {\n const maxBytes = options?.maxBytes ? Number(options.maxBytes) : undefined;\n return tsplus_module_24.scoped(tsplus_module_2.flatMap((stream) => tsplus_module_2.async((resume) => {\n let string = \"\";\n let bytes = 0;\n // @ts-expect-error\n stream.once(\"error\", (err) => {\n resume(tsplus_module_2.failNow(onFailure(err), fileName_1 + \":286:28\"));\n });\n // @ts-expect-error\n stream.once(\"end\", () => {\n resume(tsplus_module_2.succeedNow(string, fileName_1 + \":290:31\"));\n });\n // @ts-expect-error\n stream.on(\"data\", (chunk) => {\n string += chunk;\n bytes += Buffer.byteLength(chunk);\n if (maxBytes && bytes > maxBytes) {\n resume(tsplus_module_2.failNow(onFailure(new Error(\"maxBytes exceeded\")), fileName_1 + \":297:30\"));\n }\n });\n }), fileName_1 + \":280:13\")(tsplus_module_20.acquireRelease(() => tsplus_module_2.succeed(() => {\n const stream = readable();\n stream.setEncoding(options?.encoding ?? \"utf8\");\n return stream;\n }, fileName_1 + \":266:12\"), (stream) => tsplus_module_2.succeed(() => {\n // @ts-expect-error\n stream.removeAllListeners();\n if (\"closed\" in stream && !stream.closed) {\n stream.destroy();\n }\n }, fileName_1 + \":272:9\"), fileName_1 + \":271:20\")), fileName_1 + \":301:6\");\n}\nexport function toUint8Array(readable, onFailure, options = {}) {\n const maxBytes = options.maxBytes ? Number(options.maxBytes) : undefined;\n return tsplus_module_24.scoped(tsplus_module_2.flatMap((stream) => tsplus_module_2.async((resume) => {\n let buffer = Buffer.alloc(0);\n let bytes = 0;\n // @ts-expect-error\n stream.once(\"error\", (err) => {\n resume(tsplus_module_2.failNow(onFailure(err), fileName_1 + \":328:28\"));\n });\n // @ts-expect-error\n stream.once(\"end\", () => {\n resume(tsplus_module_2.succeedNow(buffer, fileName_1 + \":332:31\"));\n });\n // @ts-expect-error\n stream.on(\"data\", (chunk) => {\n buffer = Buffer.concat([buffer, chunk]);\n bytes += chunk.length;\n if (maxBytes && bytes > maxBytes) {\n resume(tsplus_module_2.failNow(onFailure(new Error(\"maxBytes exceeded\")), fileName_1 + \":339:30\"));\n }\n });\n }), fileName_1 + \":322:13\")(tsplus_module_20.acquireRelease(() => tsplus_module_2.succeed(readable, fileName_1 + \":312:12\"), (stream) => tsplus_module_2.succeed(() => {\n // @ts-expect-error\n stream.removeAllListeners();\n if (\"closed\" in stream && !stream.closed) {\n stream.destroy();\n }\n }, fileName_1 + \":314:9\"), fileName_1 + \":313:20\")), fileName_1 + \":343:6\");\n}\n//# sourceMappingURL=api.js.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,aAAa;AA0BnB,IAAa,gBAAb,MAA2B;CACvB;CACA,OAAO;CACP,YAAY,OAAO;AACf,OAAK,QAAQ;;;AAGrB,SAAgB,aAAa,UAAU,SAAS,WAAW;AACvD,QAAO,IAAI,OAAO,oBAAoB,UAAU,SAAS,UAAU,CAAC;;AAExE,SAAS,oBAAoB,UAAU,SAAS,WAAW;AACvD,QAAO,gBAAgB,mBAAmB,gBAAgB,KAAK,CAAC,UAAU,WAAW,cAAc,UAAU,OAAO,QAAQ,EAAE,aAAa,SAAS,CAAC,gBAAgB,IAAI,gBAAgB,cAAc,aAAa,SAAS,EAAE,aAAa,SAAS,CAAC,gBAAgB,QAAQ,UAAU,aAAa,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAU,WAAW,aAAa,UAAU,OAAO,UAAU,GAAG,CAAC,UAAU,WAAW,gBAAgB,SAAS,gBAAgB,SAAS,OAAO,aAAa,SAAS,EAAE,aAAa,SAAS,CAAC,gBAAgB,cAAc;AAE3gB,WAAS,oBAAoB;AAC7B,MAAI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Q;AAEZ,SAAO,KAAK,UAAU,QAAQ;AAC1B,UAAO,gBAAgB,QAAQ,UAAU,IAAI,EAAE,aAAa,UAAU,CAAC;IACzE;AAEF,SAAO,KAAK,aAAa;AACrB,UAAO,gBAAgB,WAAW,QAAQ,aAAa,UAAU,CAAC;IACpE;AAEF,SAAO,GAAG,SAAS,UAAU;AACzB,YAAS,OAAO,OAAO,CAAC,QAAQ,MAAM,CAAC;AACvC,YAAS,MAAM;AACf,OAAI,YAAY,QAAQ,SACpB,QAAO,gBAAgB,QAAQ,0BAAU,IAAI,MAAM,oBAAoB,CAAC,EAAE,aAAa,UAAU,CAAC;IAExG;GACJ,EAAE,aAAa,UAAU,CAAC,iBAAiB,qBAAqB,gBAAgB,QAAQ,UAAU,aAAa,UAAU,GAAG,WAAW,gBAAgB,cAAc;AAEnK,SAAO,oBAAoB;AAC3B,MAAI,YAAY,UAAU,CAAC,OAAO,OAC9B,QAAO,SAAS;IAErB,aAAa,SAAS,EAAE,aAAa,UAAU,CAAC,EAAE,aAAa,SAAS"}
|
package/_mjs/stream.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
//# sourceMappingURL=stream.mjs.map
|
|
1
|
+
import { ReadableError, TransformError, fromReadable, fromWritable, fromWritableChannel, toString, toUint8Array, transform } from "./stream/api.mjs";
|
|
2
|
+
export { ReadableError, TransformError, fromReadable, fromWritable, fromWritableChannel, toString, toUint8Array, transform };
|
package/_src/fs/api.ts
CHANGED
|
@@ -5,13 +5,12 @@ type ErrnoException = NodeJS.ErrnoException;
|
|
|
5
5
|
interface FileDescriptorN extends HKT {
|
|
6
6
|
type: FileDescriptor;
|
|
7
7
|
}
|
|
8
|
-
export interface FileDescriptor
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
> {}
|
|
8
|
+
export interface FileDescriptor extends Newtype<
|
|
9
|
+
{
|
|
10
|
+
readonly FileDescriptor: unique symbol;
|
|
11
|
+
},
|
|
12
|
+
number
|
|
13
|
+
> {}
|
|
15
14
|
export const FileDescriptor = Newtype<FileDescriptorN>();
|
|
16
15
|
|
|
17
16
|
function unitErrorCallback(cb: (_: IO<never, ErrnoException, void>) => void): (err: ErrnoException | null) => void {
|
|
@@ -409,9 +408,9 @@ export function rm(path: fs.PathLike, options?: fs.RmOptions): FIO<ErrnoExceptio
|
|
|
409
408
|
});
|
|
410
409
|
}
|
|
411
410
|
|
|
412
|
-
export function rmdir(path: fs.PathLike
|
|
411
|
+
export function rmdir(path: fs.PathLike): FIO<ErrnoException, void> {
|
|
413
412
|
return IO.async<never, NodeJS.ErrnoException, void>((cb) => {
|
|
414
|
-
fs.rmdir(path,
|
|
413
|
+
fs.rmdir(path, unitErrorCallback(cb));
|
|
415
414
|
});
|
|
416
415
|
}
|
|
417
416
|
|
package/_src/stream/api.ts
CHANGED
|
@@ -28,6 +28,7 @@ function fromReadableChannel<E, A = Uint8Array>(
|
|
|
28
28
|
([readable, queue]) => readableTake(readable, queue, chunkSize),
|
|
29
29
|
([readable, queue]) =>
|
|
30
30
|
IO(() => {
|
|
31
|
+
// @ts-expect-error
|
|
31
32
|
readable.removeAllListeners();
|
|
32
33
|
if ("closed" in readable && !readable.closed) {
|
|
33
34
|
readable.destroy();
|
|
@@ -42,15 +43,18 @@ function readableOffer<E>(
|
|
|
42
43
|
onError: (error: unknown) => E,
|
|
43
44
|
) {
|
|
44
45
|
return IO(() => {
|
|
46
|
+
// @ts-expect-error
|
|
45
47
|
readable.on("readable", () => {
|
|
46
48
|
const size = queue.unsafeSize;
|
|
47
49
|
if (size.isJust() && size.value <= 0) {
|
|
48
50
|
queue.offer(Either.right(void 0)).unsafeRun;
|
|
49
51
|
}
|
|
50
52
|
});
|
|
53
|
+
// @ts-expect-error
|
|
51
54
|
readable.on("error", (err) => {
|
|
52
55
|
queue.unsafeOffer(Either.left(Exit.fail(onError(err))));
|
|
53
56
|
});
|
|
57
|
+
// @ts-expect-error
|
|
54
58
|
readable.on("end", () => {
|
|
55
59
|
queue.unsafeOffer(Either.left(Exit.unit));
|
|
56
60
|
});
|
|
@@ -129,6 +133,7 @@ function writeInput<IE, A>(
|
|
|
129
133
|
if ("closed" in writable && writable.closed) {
|
|
130
134
|
resume(IO.unit);
|
|
131
135
|
} else {
|
|
136
|
+
// @ts-expect-error
|
|
132
137
|
writable.once("finish", () => resume(IO.unit));
|
|
133
138
|
}
|
|
134
139
|
})
|
|
@@ -167,6 +172,7 @@ function writeIO<A>(writable: stream.Writable | NodeJS.WritableStream, encoding?
|
|
|
167
172
|
|
|
168
173
|
if (!success) {
|
|
169
174
|
return IO.async((k) => {
|
|
175
|
+
// @ts-expect-error
|
|
170
176
|
writable.once("drain", () => {
|
|
171
177
|
k(IO.unit);
|
|
172
178
|
});
|
|
@@ -194,7 +200,9 @@ function writableOutput<IE, OE>(
|
|
|
194
200
|
function handleError(err: unknown) {
|
|
195
201
|
future.unsafeDone(IO.failNow(onError(err)));
|
|
196
202
|
}
|
|
203
|
+
// @ts-expect-error
|
|
197
204
|
writable.on("error", handleError);
|
|
205
|
+
// @ts-expect-error
|
|
198
206
|
return future.await.ensuring(IO(writable.removeListener("error", handleError)));
|
|
199
207
|
}),
|
|
200
208
|
);
|
|
@@ -262,6 +270,7 @@ export function toString<E>(
|
|
|
262
270
|
})
|
|
263
271
|
.acquireRelease((stream) =>
|
|
264
272
|
IO(() => {
|
|
273
|
+
// @ts-expect-error
|
|
265
274
|
stream.removeAllListeners();
|
|
266
275
|
if ("closed" in stream && !stream.closed) {
|
|
267
276
|
stream.destroy();
|
|
@@ -272,12 +281,15 @@ export function toString<E>(
|
|
|
272
281
|
IO.async<never, E, string>((resume) => {
|
|
273
282
|
let string = "";
|
|
274
283
|
let bytes = 0;
|
|
284
|
+
// @ts-expect-error
|
|
275
285
|
stream.once("error", (err) => {
|
|
276
286
|
resume(IO.failNow(onFailure(err)));
|
|
277
287
|
});
|
|
288
|
+
// @ts-expect-error
|
|
278
289
|
stream.once("end", () => {
|
|
279
290
|
resume(IO.succeedNow(string));
|
|
280
291
|
});
|
|
292
|
+
// @ts-expect-error
|
|
281
293
|
stream.on("data", (chunk) => {
|
|
282
294
|
string += chunk;
|
|
283
295
|
bytes += Buffer.byteLength(chunk);
|
|
@@ -300,6 +312,7 @@ export function toUint8Array<E>(
|
|
|
300
312
|
return IO(readable)
|
|
301
313
|
.acquireRelease((stream) =>
|
|
302
314
|
IO(() => {
|
|
315
|
+
// @ts-expect-error
|
|
303
316
|
stream.removeAllListeners();
|
|
304
317
|
if ("closed" in stream && !stream.closed) {
|
|
305
318
|
stream.destroy();
|
|
@@ -310,12 +323,15 @@ export function toUint8Array<E>(
|
|
|
310
323
|
IO.async<never, E, Buffer>((resume) => {
|
|
311
324
|
let buffer = Buffer.alloc(0);
|
|
312
325
|
let bytes = 0;
|
|
326
|
+
// @ts-expect-error
|
|
313
327
|
stream.once("error", (err) => {
|
|
314
328
|
resume(IO.failNow(onFailure(err)));
|
|
315
329
|
});
|
|
330
|
+
// @ts-expect-error
|
|
316
331
|
stream.once("end", () => {
|
|
317
332
|
resume(IO.succeedNow(buffer));
|
|
318
333
|
});
|
|
334
|
+
// @ts-expect-error
|
|
319
335
|
stream.on("data", (chunk) => {
|
|
320
336
|
buffer = Buffer.concat([buffer, chunk]);
|
|
321
337
|
bytes += chunk.length;
|
package/fs/api.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ export declare function realpathNative(path: fs.PathLike, options: {
|
|
|
99
99
|
}): FIO<ErrnoException, Buffer>;
|
|
100
100
|
export declare function rename(oldPath: fs.PathLike, newPath: fs.PathLike): FIO<ErrnoException, void>;
|
|
101
101
|
export declare function rm(path: fs.PathLike, options?: fs.RmOptions): FIO<ErrnoException, void>;
|
|
102
|
-
export declare function rmdir(path: fs.PathLike
|
|
102
|
+
export declare function rmdir(path: fs.PathLike): FIO<ErrnoException, void>;
|
|
103
103
|
export declare function stat(path: fs.PathLike, options?: {
|
|
104
104
|
bigint?: false;
|
|
105
105
|
}): FIO<ErrnoException, fs.Stats>;
|