@fncts/node 0.0.44 → 0.0.46
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/fs/api.cjs +286 -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 +59 -60
- package/_cjs/http/IncomingMessage.cjs.map +1 -1
- package/_cjs/http/Server.cjs +179 -195
- package/_cjs/http/Server.cjs.map +1 -1
- package/_cjs/http/ServerRequest.cjs +40 -43
- package/_cjs/http/ServerRequest.cjs.map +1 -1
- package/_cjs/index.cjs +0 -2
- package/_cjs/rolldown-runtime.cjs +27 -0
- package/_cjs/stream/api.cjs +214 -238
- package/_cjs/stream/api.cjs.map +1 -1
- package/_cjs/stream.cjs +10 -17
- package/_mjs/fs/api.mjs +295 -302
- package/_mjs/fs/api.mjs.map +1 -1
- package/_mjs/fs.mjs +1 -3
- package/_mjs/global.mjs +0 -2
- package/_mjs/http/IncomingMessage.mjs +48 -50
- package/_mjs/http/IncomingMessage.mjs.map +1 -1
- package/_mjs/http/Server.mjs +138 -169
- package/_mjs/http/Server.mjs.map +1 -1
- package/_mjs/http/ServerRequest.mjs +34 -32
- package/_mjs/http/ServerRequest.mjs.map +1 -1
- package/_mjs/index.mjs +0 -2
- package/_mjs/stream/api.mjs +163 -205
- package/_mjs/stream/api.mjs.map +1 -1
- package/_mjs/stream.mjs +1 -3
- package/_src/fs/api.ts +6 -7
- 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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
Object.defineProperty(exports, "__toESM", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function() {
|
|
25
|
+
return __toESM;
|
|
26
|
+
}
|
|
27
|
+
});
|
package/_cjs/stream/api.cjs
CHANGED
|
@@ -1,266 +1,242 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../rolldown-runtime.cjs");
|
|
3
|
+
let _fncts_io_Queue_constructors = require("@fncts/io/Queue/constructors");
|
|
4
|
+
_fncts_io_Queue_constructors = require_rolldown_runtime.__toESM(_fncts_io_Queue_constructors, 1);
|
|
5
|
+
let _fncts_io_IO_api = require("@fncts/io/IO/api");
|
|
6
|
+
_fncts_io_IO_api = require_rolldown_runtime.__toESM(_fncts_io_IO_api, 1);
|
|
7
|
+
let _fncts_io_Queue_api_operations = require("@fncts/io/Queue/api/operations");
|
|
8
|
+
_fncts_io_Queue_api_operations = require_rolldown_runtime.__toESM(_fncts_io_Queue_api_operations, 1);
|
|
9
|
+
let _fncts_io_Channel_api = require("@fncts/io/Channel/api");
|
|
10
|
+
_fncts_io_Channel_api = require_rolldown_runtime.__toESM(_fncts_io_Channel_api, 1);
|
|
11
|
+
let _fncts_base_data_Maybe_definition = require("@fncts/base/data/Maybe/definition");
|
|
12
|
+
_fncts_base_data_Maybe_definition = require_rolldown_runtime.__toESM(_fncts_base_data_Maybe_definition, 1);
|
|
13
|
+
let _fncts_base_data_Either_constructors = require("@fncts/base/data/Either/constructors");
|
|
14
|
+
_fncts_base_data_Either_constructors = require_rolldown_runtime.__toESM(_fncts_base_data_Either_constructors, 1);
|
|
15
|
+
let _fncts_io_IO_runtime = require("@fncts/io/IO/runtime");
|
|
16
|
+
_fncts_io_IO_runtime = require_rolldown_runtime.__toESM(_fncts_io_IO_runtime, 1);
|
|
17
|
+
let _fncts_base_data_Exit_constructors = require("@fncts/base/data/Exit/constructors");
|
|
18
|
+
_fncts_base_data_Exit_constructors = require_rolldown_runtime.__toESM(_fncts_base_data_Exit_constructors, 1);
|
|
19
|
+
let _fncts_io_Channel_core_api = require("@fncts/io/Channel/core-api");
|
|
20
|
+
_fncts_io_Channel_core_api = require_rolldown_runtime.__toESM(_fncts_io_Channel_core_api, 1);
|
|
21
|
+
let _fncts_base_data_Exit_api = require("@fncts/base/data/Exit/api");
|
|
22
|
+
_fncts_base_data_Exit_api = require_rolldown_runtime.__toESM(_fncts_base_data_Exit_api, 1);
|
|
23
|
+
let _fncts_base_data_Either_destructors = require("@fncts/base/data/Either/destructors");
|
|
24
|
+
_fncts_base_data_Either_destructors = require_rolldown_runtime.__toESM(_fncts_base_data_Either_destructors, 1);
|
|
25
|
+
let _fncts_base_collection_immutable_Conc_definition = require("@fncts/base/collection/immutable/Conc/definition");
|
|
26
|
+
_fncts_base_collection_immutable_Conc_definition = require_rolldown_runtime.__toESM(_fncts_base_collection_immutable_Conc_definition, 1);
|
|
27
|
+
let _fncts_io_Sink_api = require("@fncts/io/Sink/api");
|
|
28
|
+
_fncts_io_Sink_api = require_rolldown_runtime.__toESM(_fncts_io_Sink_api, 1);
|
|
29
|
+
let _fncts_io_Future_api = require("@fncts/io/Future/api");
|
|
30
|
+
_fncts_io_Future_api = require_rolldown_runtime.__toESM(_fncts_io_Future_api, 1);
|
|
31
|
+
let _fncts_io_Future_constructors = require("@fncts/io/Future/constructors");
|
|
32
|
+
_fncts_io_Future_constructors = require_rolldown_runtime.__toESM(_fncts_io_Future_constructors, 1);
|
|
33
|
+
let _fncts_io_IO_api_asyncIO = require("@fncts/io/IO/api/asyncIO");
|
|
34
|
+
_fncts_io_IO_api_asyncIO = require_rolldown_runtime.__toESM(_fncts_io_IO_api_asyncIO, 1);
|
|
35
|
+
let _fncts_io_IO_api_interrupt = require("@fncts/io/IO/api/interrupt");
|
|
36
|
+
_fncts_io_IO_api_interrupt = require_rolldown_runtime.__toESM(_fncts_io_IO_api_interrupt, 1);
|
|
37
|
+
let _fncts_base_collection_immutable_Conc_api = require("@fncts/base/collection/immutable/Conc/api");
|
|
38
|
+
_fncts_base_collection_immutable_Conc_api = require_rolldown_runtime.__toESM(_fncts_base_collection_immutable_Conc_api, 1);
|
|
39
|
+
let _fncts_io_Sink_definition = require("@fncts/io/Sink/definition");
|
|
40
|
+
_fncts_io_Sink_definition = require_rolldown_runtime.__toESM(_fncts_io_Sink_definition, 1);
|
|
41
|
+
let _fncts_io_IO_api_acquireRelease = require("@fncts/io/IO/api/acquireRelease");
|
|
42
|
+
_fncts_io_IO_api_acquireRelease = require_rolldown_runtime.__toESM(_fncts_io_IO_api_acquireRelease, 1);
|
|
43
|
+
let _fncts_io_Stream_api = require("@fncts/io/Stream/api");
|
|
44
|
+
_fncts_io_Stream_api = require_rolldown_runtime.__toESM(_fncts_io_Stream_api, 1);
|
|
45
|
+
let _fncts_base_collection_immutable_Conc_constructors = require("@fncts/base/collection/immutable/Conc/constructors");
|
|
46
|
+
_fncts_base_collection_immutable_Conc_constructors = require_rolldown_runtime.__toESM(_fncts_base_collection_immutable_Conc_constructors, 1);
|
|
47
|
+
let _fncts_base_data_Maybe_constructors = require("@fncts/base/data/Maybe/constructors");
|
|
48
|
+
_fncts_base_data_Maybe_constructors = require_rolldown_runtime.__toESM(_fncts_base_data_Maybe_constructors, 1);
|
|
49
|
+
let _fncts_io_IO_api_scoped = require("@fncts/io/IO/api/scoped");
|
|
50
|
+
_fncts_io_IO_api_scoped = require_rolldown_runtime.__toESM(_fncts_io_IO_api_scoped, 1);
|
|
51
|
+
let _fncts_io_Stream = require("@fncts/io/Stream");
|
|
52
|
+
// build/esm/stream/api.js
|
|
39
53
|
const fileName_1 = "(@fncts/node) src/stream/api.ts";
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
exports.ReadableError = ReadableError;
|
|
54
|
+
var ReadableError = class {
|
|
55
|
+
error;
|
|
56
|
+
_tag = "ReadableError";
|
|
57
|
+
constructor(error) {
|
|
58
|
+
this.error = error;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
48
61
|
function fromReadable(readable, onError, chunkSize) {
|
|
49
|
-
|
|
62
|
+
return new _fncts_io_Stream.Stream(fromReadableChannel(readable, onError, chunkSize));
|
|
50
63
|
}
|
|
51
64
|
function fromReadableChannel(evaluate, onError, chunkSize) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
readable.destroy();
|
|
57
|
-
}
|
|
58
|
-
}, fileName_1 + ":30:9")));
|
|
65
|
+
return _fncts_io_Channel_api.acquireReleaseWith(_fncts_io_IO_api.tap(([readable, queue]) => readableOffer(readable, queue, onError), fileName_1 + ":27:11")(_fncts_io_IO_api.zip(_fncts_io_Queue_constructors.makeUnbounded(fileName_1 + ":26:31"), fileName_1 + ":26:11")(_fncts_io_IO_api.succeed(evaluate, fileName_1 + ":25:7"))), ([readable, queue]) => readableTake(readable, queue, chunkSize), ([readable, queue]) => _fncts_io_IO_api.zipRight(_fncts_io_Queue_api_operations.shutdown(queue, fileName_1 + ":36:17"), fileName_1 + ":36:11")(_fncts_io_IO_api.succeed(() => {
|
|
66
|
+
readable.removeAllListeners();
|
|
67
|
+
if ("closed" in readable && !readable.closed) readable.destroy();
|
|
68
|
+
}, fileName_1 + ":30:9")));
|
|
59
69
|
}
|
|
60
70
|
function readableOffer(readable, queue, onError) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
readable.on("end", () => {
|
|
75
|
-
tsplus_module_3.unsafeOffer(tsplus_module_6.left(tsplus_module_8.unit, fileName_1 + ":59:36"), fileName_1 + ":59:24")(queue);
|
|
76
|
-
});
|
|
77
|
-
if (readable.readable) {
|
|
78
|
-
tsplus_module_3.unsafeOffer(tsplus_module_6.right(void 0, fileName_1 + ":62:37"), fileName_1 + ":62:24")(queue);
|
|
79
|
-
}
|
|
80
|
-
}, fileName_1 + ":45:12");
|
|
71
|
+
return _fncts_io_IO_api.succeed(() => {
|
|
72
|
+
readable.on("readable", () => {
|
|
73
|
+
const size = _fncts_io_Queue_api_operations.unsafeSize(queue, fileName_1 + ":48:25");
|
|
74
|
+
if (_fncts_base_data_Maybe_definition.isJust(size) && size.value <= 0) _fncts_io_IO_runtime.unsafeRun(_fncts_io_Queue_api_operations.offer(_fncts_base_data_Either_constructors.right(void 0, fileName_1 + ":50:33"), fileName_1 + ":50:20")(queue));
|
|
75
|
+
});
|
|
76
|
+
readable.on("error", (err) => {
|
|
77
|
+
_fncts_io_Queue_api_operations.unsafeOffer(_fncts_base_data_Either_constructors.left(_fncts_base_data_Exit_constructors.fail(onError(err), fileName_1 + ":55:46"), fileName_1 + ":55:36"), fileName_1 + ":55:24")(queue);
|
|
78
|
+
});
|
|
79
|
+
readable.on("end", () => {
|
|
80
|
+
_fncts_io_Queue_api_operations.unsafeOffer(_fncts_base_data_Either_constructors.left(_fncts_base_data_Exit_constructors.unit, fileName_1 + ":59:36"), fileName_1 + ":59:24")(queue);
|
|
81
|
+
});
|
|
82
|
+
if (readable.readable) _fncts_io_Queue_api_operations.unsafeOffer(_fncts_base_data_Either_constructors.right(void 0, fileName_1 + ":62:37"), fileName_1 + ":62:24")(queue);
|
|
83
|
+
}, fileName_1 + ":45:12");
|
|
81
84
|
}
|
|
82
85
|
function readableTake(readable, queue, chunkSize) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
const read = readChunkChannel(readable, chunkSize);
|
|
87
|
+
const loop = _fncts_io_Channel_core_api.flatMap((either) => _fncts_base_data_Either_destructors.match((exit) => _fncts_base_data_Exit_api.match((cause) => _fncts_io_Channel_core_api.failCauseNow(cause), () => _fncts_io_Channel_api.unit)(exit), () => _fncts_io_Channel_core_api.flatMap(() => loop)(read))(either))(_fncts_io_Channel_api.fromIO(() => _fncts_io_Queue_api_operations.take(queue, fileName_1 + ":73:100")));
|
|
88
|
+
return loop;
|
|
86
89
|
}
|
|
87
90
|
function readChunkChannel(readable, chunkSize) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
return _fncts_io_Channel_api.defer(() => {
|
|
92
|
+
const arr = [];
|
|
93
|
+
let chunk = readable.read(chunkSize);
|
|
94
|
+
while (chunk !== null) {
|
|
95
|
+
arr.push(chunk);
|
|
96
|
+
chunk = readable.read(chunkSize);
|
|
97
|
+
}
|
|
98
|
+
return _fncts_io_Channel_api.write(() => _fncts_base_collection_immutable_Conc_definition.fromArray(arr));
|
|
99
|
+
});
|
|
97
100
|
}
|
|
98
101
|
function fromWritable(writable, onError, options) {
|
|
99
|
-
|
|
102
|
+
return _fncts_io_Sink_api.fromChannel(fromWritableChannel(writable, onError, options), fileName_1 + ":109:26");
|
|
100
103
|
}
|
|
101
104
|
function fromWritableChannel(writable, onError, options) {
|
|
102
|
-
|
|
105
|
+
return _fncts_io_Channel_core_api.flatMap(([writable, future]) => _fncts_io_Channel_api.embedInput(writeInput(writable, (cause) => _fncts_io_Future_api.failCause(cause, fileName_1 + ":119:62")(future), options, _fncts_io_Future_api.fulfill(_fncts_io_IO_api.unit, fileName_1 + ":119:94")(future)))(writableOutput(writable, future, onError)))(_fncts_io_Channel_api.fromIO(() => _fncts_io_IO_api.zip(_fncts_io_Future_constructors.make(fileName_1 + ":117:53"), fileName_1 + ":117:41")(_fncts_io_IO_api.succeed(writable, fileName_1 + ":117:27"))));
|
|
103
106
|
}
|
|
104
|
-
function writeInput(writable, onFailure, {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}) : tsplus_module_2.unit;
|
|
117
|
-
return {
|
|
118
|
-
awaitRead: tsplus_module_2.unit,
|
|
119
|
-
emit: write,
|
|
120
|
-
error: cause => tsplus_module_2.zipRight(onFailure(cause), fileName_1 + ":145:30")(close),
|
|
121
|
-
done: _ => tsplus_module_2.zipRight(onDone, fileName_1 + ":146:25")(close)
|
|
122
|
-
};
|
|
107
|
+
function writeInput(writable, onFailure, { encoding, endOnDone = true } = {}, onDone = _fncts_io_IO_api.unit) {
|
|
108
|
+
const write = writeIO(writable, encoding);
|
|
109
|
+
const close = endOnDone ? _fncts_io_IO_api.async((resume) => {
|
|
110
|
+
if ("closed" in writable && writable.closed) resume(_fncts_io_IO_api.unit);
|
|
111
|
+
else writable.once("finish", () => resume(_fncts_io_IO_api.unit));
|
|
112
|
+
}) : _fncts_io_IO_api.unit;
|
|
113
|
+
return {
|
|
114
|
+
awaitRead: _fncts_io_IO_api.unit,
|
|
115
|
+
emit: write,
|
|
116
|
+
error: (cause) => _fncts_io_IO_api.zipRight(onFailure(cause), fileName_1 + ":145:30")(close),
|
|
117
|
+
done: (_) => _fncts_io_IO_api.zipRight(onDone, fileName_1 + ":146:25")(close)
|
|
118
|
+
};
|
|
123
119
|
}
|
|
124
120
|
function writeIO(writable, encoding) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
return tsplus_module_2.unit;
|
|
150
|
-
}
|
|
151
|
-
}, () => {
|
|
152
|
-
next = iterator.next();
|
|
153
|
-
});
|
|
154
|
-
}, fileName_1 + ":155:24");
|
|
155
|
-
}
|
|
156
|
-
};
|
|
121
|
+
return (chunk) => {
|
|
122
|
+
if (chunk.length === 0) return _fncts_io_IO_api.unit;
|
|
123
|
+
else return _fncts_io_IO_api_asyncIO.asyncIO((resume) => {
|
|
124
|
+
const iterator = chunk[Symbol.iterator]();
|
|
125
|
+
let done = false;
|
|
126
|
+
let next = iterator.next();
|
|
127
|
+
return _fncts_io_IO_api.whileLoop(() => !done, () => {
|
|
128
|
+
if (next.done) return _fncts_io_IO_api.succeed(() => {
|
|
129
|
+
done = true;
|
|
130
|
+
resume(_fncts_io_IO_api.unit);
|
|
131
|
+
}, fileName_1 + ":165:24");
|
|
132
|
+
if (!writable.write(next.value, encoding)) return _fncts_io_IO_api.async((k) => {
|
|
133
|
+
writable.once("drain", () => {
|
|
134
|
+
k(_fncts_io_IO_api.unit);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
else return _fncts_io_IO_api.unit;
|
|
138
|
+
}, () => {
|
|
139
|
+
next = iterator.next();
|
|
140
|
+
});
|
|
141
|
+
}, fileName_1 + ":155:24");
|
|
142
|
+
};
|
|
157
143
|
}
|
|
158
144
|
function writableOutput(writable, future, onError) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
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"));
|
|
167
|
-
}, fileName_1 + ":199:13"));
|
|
168
|
-
}
|
|
169
|
-
class TransformError {
|
|
170
|
-
error;
|
|
171
|
-
_tag = "TransformError";
|
|
172
|
-
constructor(error) {
|
|
173
|
-
this.error = error;
|
|
174
|
-
}
|
|
145
|
+
return _fncts_io_Channel_api.fromIO(() => _fncts_io_IO_api.defer(() => {
|
|
146
|
+
function handleError(err) {
|
|
147
|
+
_fncts_io_Future_api.unsafeDone(_fncts_io_IO_api.failNow(onError(err), fileName_1 + ":201:37"), fileName_1 + ":201:26")(future);
|
|
148
|
+
}
|
|
149
|
+
writable.on("error", handleError);
|
|
150
|
+
return _fncts_io_IO_api_interrupt.ensuring(_fncts_io_IO_api.succeed(writable.removeListener("error", handleError), fileName_1 + ":206:38"), fileName_1 + ":206:35")(_fncts_io_Future_api.wait(future, fileName_1 + ":206:20"));
|
|
151
|
+
}, fileName_1 + ":199:13"));
|
|
175
152
|
}
|
|
153
|
+
var TransformError = class {
|
|
154
|
+
error;
|
|
155
|
+
_tag = "TransformError";
|
|
156
|
+
constructor(error) {
|
|
157
|
+
this.error = error;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
176
160
|
/**
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
exports.TransformError = TransformError;
|
|
161
|
+
* @tsplus pipeable fncts.io.Stream transform
|
|
162
|
+
*/
|
|
180
163
|
function transform(transform) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
164
|
+
return (self) => {
|
|
165
|
+
const scopedSink = _fncts_io_IO_api.map((transform) => {
|
|
166
|
+
const endTransform = _fncts_io_IO_api.succeed(() => transform.end(), fileName_1 + ":224:40");
|
|
167
|
+
const reader = _fncts_io_Channel_api.readWith((inp) => _fncts_io_Channel_api.unwrap(() => _fncts_io_IO_api.async((cb) => {
|
|
168
|
+
transform.write(_fncts_base_collection_immutable_Conc_api.toBuffer(inp), (err) => {
|
|
169
|
+
err ? cb(_fncts_io_IO_api.failNow(new TransformError(err), fileName_1 + ":230:38")) : _fncts_io_IO_api.succeedNow(reader, fileName_1 + ":230:80");
|
|
170
|
+
});
|
|
171
|
+
})), (err) => _fncts_io_Channel_api.unwrap(() => _fncts_io_IO_api.map(() => _fncts_io_Channel_api.failNow(err), fileName_1 + ":234:51")(endTransform)), () => _fncts_io_Channel_api.unwrap(() => _fncts_io_IO_api.map(() => _fncts_io_Channel_api.unit, fileName_1 + ":235:48")(endTransform)));
|
|
172
|
+
return [transform, new _fncts_io_Sink_definition.Sink(reader)];
|
|
173
|
+
}, fileName_1 + ":223:11")(_fncts_io_IO_api_acquireRelease.acquireRelease(() => _fncts_io_IO_api.succeed(transform, fileName_1 + ":221:34"), (transform) => _fncts_io_IO_api.succeed(() => transform.destroy(), fileName_1 + ":222:48"), fileName_1 + ":222:22"));
|
|
174
|
+
return _fncts_io_Stream_api.flatMap(([transform, sink]) => _fncts_io_Stream_api.ensuring(_fncts_io_IO_api.succeed(() => transform.removeAllListeners(), fileName_1 + ":252:20"), fileName_1 + ":252:17")(_fncts_io_Stream_api.asyncIO((cb) => _fncts_io_IO_api.zipRight(_fncts_io_Stream_api.run(sink, fileName_1 + ":251:29")(self), fileName_1 + ":251:20")(_fncts_io_IO_api.succeed(() => {
|
|
175
|
+
transform.on("data", (chunk) => {
|
|
176
|
+
cb(_fncts_io_IO_api.succeed(() => _fncts_base_collection_immutable_Conc_constructors.fromBuffer(chunk), fileName_1 + ":243:26"));
|
|
177
|
+
});
|
|
178
|
+
transform.on("error", (err) => {
|
|
179
|
+
cb(_fncts_io_IO_api.failNow(_fncts_base_data_Maybe_constructors.just(new TransformError(err), fileName_1 + ":246:31"), fileName_1 + ":246:26"));
|
|
180
|
+
});
|
|
181
|
+
transform.on("end", () => {
|
|
182
|
+
cb(_fncts_io_IO_api.failNow(_fncts_base_data_Maybe_constructors.nothing(fileName_1 + ":249:34"), fileName_1 + ":249:26"));
|
|
183
|
+
});
|
|
184
|
+
}, fileName_1 + ":241:19")))), fileName_1 + ":239:45")(_fncts_io_Stream_api.scoped(() => scopedSink, fileName_1 + ":239:25"));
|
|
185
|
+
};
|
|
203
186
|
}
|
|
204
187
|
function toString(readable, onFailure, options) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return stream;
|
|
229
|
-
}, fileName_1 + ":266:12"), stream => tsplus_module_2.succeed(() => {
|
|
230
|
-
// @ts-expect-error
|
|
231
|
-
stream.removeAllListeners();
|
|
232
|
-
if ("closed" in stream && !stream.closed) {
|
|
233
|
-
stream.destroy();
|
|
234
|
-
}
|
|
235
|
-
}, fileName_1 + ":272:9"), fileName_1 + ":271:20")), fileName_1 + ":301:6");
|
|
188
|
+
const maxBytes = options?.maxBytes ? Number(options.maxBytes) : void 0;
|
|
189
|
+
return _fncts_io_IO_api_scoped.scoped(_fncts_io_IO_api.flatMap((stream) => _fncts_io_IO_api.async((resume) => {
|
|
190
|
+
let string = "";
|
|
191
|
+
let bytes = 0;
|
|
192
|
+
stream.once("error", (err) => {
|
|
193
|
+
resume(_fncts_io_IO_api.failNow(onFailure(err), fileName_1 + ":286:28"));
|
|
194
|
+
});
|
|
195
|
+
stream.once("end", () => {
|
|
196
|
+
resume(_fncts_io_IO_api.succeedNow(string, fileName_1 + ":290:31"));
|
|
197
|
+
});
|
|
198
|
+
stream.on("data", (chunk) => {
|
|
199
|
+
string += chunk;
|
|
200
|
+
bytes += Buffer.byteLength(chunk);
|
|
201
|
+
if (maxBytes && bytes > maxBytes) resume(_fncts_io_IO_api.failNow(onFailure(/* @__PURE__ */ new Error("maxBytes exceeded")), fileName_1 + ":297:30"));
|
|
202
|
+
});
|
|
203
|
+
}), fileName_1 + ":280:13")(_fncts_io_IO_api_acquireRelease.acquireRelease(() => _fncts_io_IO_api.succeed(() => {
|
|
204
|
+
const stream = readable();
|
|
205
|
+
stream.setEncoding(options?.encoding ?? "utf8");
|
|
206
|
+
return stream;
|
|
207
|
+
}, fileName_1 + ":266:12"), (stream) => _fncts_io_IO_api.succeed(() => {
|
|
208
|
+
stream.removeAllListeners();
|
|
209
|
+
if ("closed" in stream && !stream.closed) stream.destroy();
|
|
210
|
+
}, fileName_1 + ":272:9"), fileName_1 + ":271:20")), fileName_1 + ":301:6");
|
|
236
211
|
}
|
|
237
212
|
function toUint8Array(readable, onFailure, options = {}) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
});
|
|
258
|
-
}), fileName_1 + ":322:13")(tsplus_module_20.acquireRelease(() => tsplus_module_2.succeed(readable, fileName_1 + ":312:12"), stream => tsplus_module_2.succeed(() => {
|
|
259
|
-
// @ts-expect-error
|
|
260
|
-
stream.removeAllListeners();
|
|
261
|
-
if ("closed" in stream && !stream.closed) {
|
|
262
|
-
stream.destroy();
|
|
263
|
-
}
|
|
264
|
-
}, fileName_1 + ":314:9"), fileName_1 + ":313:20")), fileName_1 + ":343:6");
|
|
213
|
+
const maxBytes = options.maxBytes ? Number(options.maxBytes) : void 0;
|
|
214
|
+
return _fncts_io_IO_api_scoped.scoped(_fncts_io_IO_api.flatMap((stream) => _fncts_io_IO_api.async((resume) => {
|
|
215
|
+
let buffer = Buffer.alloc(0);
|
|
216
|
+
let bytes = 0;
|
|
217
|
+
stream.once("error", (err) => {
|
|
218
|
+
resume(_fncts_io_IO_api.failNow(onFailure(err), fileName_1 + ":328:28"));
|
|
219
|
+
});
|
|
220
|
+
stream.once("end", () => {
|
|
221
|
+
resume(_fncts_io_IO_api.succeedNow(buffer, fileName_1 + ":332:31"));
|
|
222
|
+
});
|
|
223
|
+
stream.on("data", (chunk) => {
|
|
224
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
225
|
+
bytes += chunk.length;
|
|
226
|
+
if (maxBytes && bytes > maxBytes) resume(_fncts_io_IO_api.failNow(onFailure(/* @__PURE__ */ new Error("maxBytes exceeded")), fileName_1 + ":339:30"));
|
|
227
|
+
});
|
|
228
|
+
}), fileName_1 + ":322:13")(_fncts_io_IO_api_acquireRelease.acquireRelease(() => _fncts_io_IO_api.succeed(readable, fileName_1 + ":312:12"), (stream) => _fncts_io_IO_api.succeed(() => {
|
|
229
|
+
stream.removeAllListeners();
|
|
230
|
+
if ("closed" in stream && !stream.closed) stream.destroy();
|
|
231
|
+
}, fileName_1 + ":314:9"), fileName_1 + ":313:20")), fileName_1 + ":343:6");
|
|
265
232
|
}
|
|
233
|
+
exports.ReadableError = ReadableError;
|
|
234
|
+
exports.TransformError = TransformError;
|
|
235
|
+
exports.fromReadable = fromReadable;
|
|
236
|
+
exports.fromWritable = fromWritable;
|
|
237
|
+
exports.fromWritableChannel = fromWritableChannel;
|
|
238
|
+
exports.toString = toString;
|
|
239
|
+
exports.toUint8Array = toUint8Array;
|
|
240
|
+
exports.transform = transform;
|
|
241
|
+
|
|
266
242
|
//# sourceMappingURL=api.cjs.map
|