@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.
@@ -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,228 +23,187 @@ 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
- export class ReadableError {
28
- error;
29
- _tag = "ReadableError";
30
- constructor(error) {
31
- this.error = error;
32
- }
33
- }
34
- export function fromReadable(readable, onError, chunkSize) {
35
- return new Stream(fromReadableChannel(readable, onError, chunkSize));
26
+ // 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));
36
37
  }
37
38
  function fromReadableChannel(evaluate, onError, chunkSize) {
38
- 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(() => {
39
- // @ts-expect-error
40
- readable.removeAllListeners();
41
- if ("closed" in readable && !readable.closed) {
42
- readable.destroy();
43
- }
44
- }, 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")));
45
43
  }
46
44
  function readableOffer(readable, queue, onError) {
47
- return tsplus_module_2.succeed(() => {
48
- // @ts-expect-error
49
- readable.on("readable", () => {
50
- const size = tsplus_module_3.unsafeSize(queue, fileName_1 + ":48:25");
51
- if (tsplus_module_5.isJust(size) && size.value <= 0) {
52
- tsplus_module_7.unsafeRun(tsplus_module_3.offer(tsplus_module_6.right(void 0, fileName_1 + ":50:33"), fileName_1 + ":50:20")(queue));
53
- }
54
- });
55
- // @ts-expect-error
56
- readable.on("error", err => {
57
- 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);
58
- });
59
- // @ts-expect-error
60
- readable.on("end", () => {
61
- tsplus_module_3.unsafeOffer(tsplus_module_6.left(tsplus_module_8.unit, fileName_1 + ":59:36"), fileName_1 + ":59:24")(queue);
62
- });
63
- if (readable.readable) {
64
- tsplus_module_3.unsafeOffer(tsplus_module_6.right(void 0, fileName_1 + ":62:37"), fileName_1 + ":62:24")(queue);
65
- }
66
- }, fileName_1 + ":45: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");
67
58
  }
68
59
  function readableTake(readable, queue, chunkSize) {
69
- const read = readChunkChannel(readable, chunkSize);
70
- 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")));
71
- return loop;
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;
72
63
  }
73
64
  function readChunkChannel(readable, chunkSize) {
74
- return tsplus_module_4.defer(() => {
75
- const arr = [];
76
- let chunk = readable.read(chunkSize);
77
- while (chunk !== null) {
78
- arr.push(chunk);
79
- chunk = readable.read(chunkSize);
80
- }
81
- return tsplus_module_4.write(() => tsplus_module_12.fromArray(arr));
82
- });
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
+ });
83
74
  }
84
- export function fromWritable(writable, onError, options) {
85
- return tsplus_module_13.fromChannel(fromWritableChannel(writable, onError, options), fileName_1 + ":109:26");
75
+ function fromWritable(writable, onError, options) {
76
+ return tsplus_module_13.fromChannel(fromWritableChannel(writable, onError, options), fileName_1 + ":109:26");
86
77
  }
87
- export function fromWritableChannel(writable, onError, options) {
88
- 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"))));
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"))));
89
80
  }
90
- function writeInput(writable, onFailure, {
91
- encoding,
92
- endOnDone = true
93
- } = {}, onDone = tsplus_module_2.unit) {
94
- const write = writeIO(writable, encoding);
95
- const close = endOnDone ? tsplus_module_2.async(resume => {
96
- if ("closed" in writable && writable.closed) {
97
- resume(tsplus_module_2.unit);
98
- } else {
99
- // @ts-expect-error
100
- writable.once("finish", () => resume(tsplus_module_2.unit));
101
- }
102
- }) : tsplus_module_2.unit;
103
- return {
104
- awaitRead: tsplus_module_2.unit,
105
- emit: write,
106
- error: cause => tsplus_module_2.zipRight(onFailure(cause), fileName_1 + ":145:30")(close),
107
- done: _ => tsplus_module_2.zipRight(onDone, fileName_1 + ":146:25")(close)
108
- };
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
+ };
109
93
  }
110
94
  function writeIO(writable, encoding) {
111
- return chunk => {
112
- if (chunk.length === 0) {
113
- return tsplus_module_2.unit;
114
- } else {
115
- return tsplus_module_16.asyncIO(resume => {
116
- const iterator = chunk[Symbol.iterator]();
117
- let done = false;
118
- let next = iterator.next();
119
- return tsplus_module_2.whileLoop(() => !done, () => {
120
- if (next.done) {
121
- return tsplus_module_2.succeed(() => {
122
- done = true;
123
- resume(tsplus_module_2.unit);
124
- }, fileName_1 + ":165:24");
125
- }
126
- const success = writable.write(next.value, encoding);
127
- if (!success) {
128
- return tsplus_module_2.async(k => {
129
- // @ts-expect-error
130
- writable.once("drain", () => {
131
- k(tsplus_module_2.unit);
132
- });
133
- });
134
- } else {
135
- return tsplus_module_2.unit;
136
- }
137
- }, () => {
138
- next = iterator.next();
139
- });
140
- }, fileName_1 + ":155:24");
141
- }
142
- };
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
+ };
143
117
  }
144
118
  function writableOutput(writable, future, onError) {
145
- return tsplus_module_4.fromIO(() => tsplus_module_2.defer(() => {
146
- function handleError(err) {
147
- tsplus_module_14.unsafeDone(tsplus_module_2.failNow(onError(err), fileName_1 + ":201:37"), fileName_1 + ":201:26")(future);
148
- }
149
- // @ts-expect-error
150
- writable.on("error", handleError);
151
- // @ts-expect-error
152
- 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"));
153
- }, fileName_1 + ":199:13"));
154
- }
155
- export class TransformError {
156
- error;
157
- _tag = "TransformError";
158
- constructor(error) {
159
- this.error = error;
160
- }
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"));
161
126
  }
127
+ var TransformError = class {
128
+ error;
129
+ _tag = "TransformError";
130
+ constructor(error) {
131
+ this.error = error;
132
+ }
133
+ };
162
134
  /**
163
- * @tsplus pipeable fncts.io.Stream transform
164
- */
165
- export function transform(transform) {
166
- return self => {
167
- const scopedSink = tsplus_module_2.map(transform => {
168
- const endTransform = tsplus_module_2.succeed(() => transform.end(), fileName_1 + ":224:40");
169
- const reader = tsplus_module_4.readWith(inp => tsplus_module_4.unwrap(() => tsplus_module_2.async(cb => {
170
- transform.write(tsplus_module_18.toBuffer(inp), err => {
171
- err ? cb(tsplus_module_2.failNow(new TransformError(err), fileName_1 + ":230:38")) : tsplus_module_2.succeedNow(reader, fileName_1 + ":230:80");
172
- });
173
- })), 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)));
174
- return [transform, new tsplus_module_19.Sink(reader)];
175
- }, 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"));
176
- 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(() => {
177
- transform.on("data", chunk => {
178
- cb(tsplus_module_2.succeed(() => tsplus_module_22.fromBuffer(chunk), fileName_1 + ":243:26"));
179
- });
180
- transform.on("error", err => {
181
- cb(tsplus_module_2.failNow(tsplus_module_23.just(new TransformError(err), fileName_1 + ":246:31"), fileName_1 + ":246:26"));
182
- });
183
- transform.on("end", () => {
184
- cb(tsplus_module_2.failNow(tsplus_module_23.nothing(fileName_1 + ":249:34"), fileName_1 + ":249:26"));
185
- });
186
- }, fileName_1 + ":241:19")))), fileName_1 + ":239:45")(tsplus_module_21.scoped(() => scopedSink, fileName_1 + ":239:25"));
187
- };
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
+ };
188
160
  }
189
- export function toString(readable, onFailure, options) {
190
- const maxBytes = options?.maxBytes ? Number(options.maxBytes) : undefined;
191
- return tsplus_module_24.scoped(tsplus_module_2.flatMap(stream => tsplus_module_2.async(resume => {
192
- let string = "";
193
- let bytes = 0;
194
- // @ts-expect-error
195
- stream.once("error", err => {
196
- resume(tsplus_module_2.failNow(onFailure(err), fileName_1 + ":286:28"));
197
- });
198
- // @ts-expect-error
199
- stream.once("end", () => {
200
- resume(tsplus_module_2.succeedNow(string, fileName_1 + ":290:31"));
201
- });
202
- // @ts-expect-error
203
- stream.on("data", chunk => {
204
- string += chunk;
205
- bytes += Buffer.byteLength(chunk);
206
- if (maxBytes && bytes > maxBytes) {
207
- resume(tsplus_module_2.failNow(onFailure(new Error("maxBytes exceeded")), fileName_1 + ":297:30"));
208
- }
209
- });
210
- }), fileName_1 + ":280:13")(tsplus_module_20.acquireRelease(() => tsplus_module_2.succeed(() => {
211
- const stream = readable();
212
- stream.setEncoding(options?.encoding ?? "utf8");
213
- return stream;
214
- }, fileName_1 + ":266:12"), stream => tsplus_module_2.succeed(() => {
215
- // @ts-expect-error
216
- stream.removeAllListeners();
217
- if ("closed" in stream && !stream.closed) {
218
- stream.destroy();
219
- }
220
- }, fileName_1 + ":272:9"), fileName_1 + ":271:20")), fileName_1 + ":301: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");
221
185
  }
222
- export function toUint8Array(readable, onFailure, options = {}) {
223
- const maxBytes = options.maxBytes ? Number(options.maxBytes) : undefined;
224
- return tsplus_module_24.scoped(tsplus_module_2.flatMap(stream => tsplus_module_2.async(resume => {
225
- let buffer = Buffer.alloc(0);
226
- let bytes = 0;
227
- // @ts-expect-error
228
- stream.once("error", err => {
229
- resume(tsplus_module_2.failNow(onFailure(err), fileName_1 + ":328:28"));
230
- });
231
- // @ts-expect-error
232
- stream.once("end", () => {
233
- resume(tsplus_module_2.succeedNow(buffer, fileName_1 + ":332:31"));
234
- });
235
- // @ts-expect-error
236
- stream.on("data", chunk => {
237
- buffer = Buffer.concat([buffer, chunk]);
238
- bytes += chunk.length;
239
- if (maxBytes && bytes > maxBytes) {
240
- resume(tsplus_module_2.failNow(onFailure(new Error("maxBytes exceeded")), fileName_1 + ":339:30"));
241
- }
242
- });
243
- }), fileName_1 + ":322:13")(tsplus_module_20.acquireRelease(() => tsplus_module_2.succeed(readable, fileName_1 + ":312:12"), stream => tsplus_module_2.succeed(() => {
244
- // @ts-expect-error
245
- stream.removeAllListeners();
246
- if ("closed" in stream && !stream.closed) {
247
- stream.destroy();
248
- }
249
- }, fileName_1 + ":314:9"), fileName_1 + ":313:20")), fileName_1 + ":343: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");
250
206
  }
207
+ export { ReadableError, TransformError, fromReadable, fromWritable, fromWritableChannel, toString, toUint8Array, transform };
208
+
251
209
  //# sourceMappingURL=api.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.mjs","names":["Stream","ReadableError","error","_tag","constructor","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;EAEHC,KAAA;EADZC,IAAI,GAAG,eAAe;EAC/BC,YAAqBF,KAAY;IAAZ,KAAAA,KAAK,GAALA,KAAK;EAAU;;AAGtC,OAAM,SAAUG,YAAYA,CAC1BC,QAAuD,EACvDC,OAA8B,EAC9BC,SAAkB;EAElB,OAAO,IAAIR,MAAM,CAAcS,mBAAmB,CAAOH,QAAQ,EAAEC,OAAO,EAAEC,SAAS,CAAC,CAAC;AACzF;AAEA,SAASC,mBAAmBA,CAC1BC,QAAuD,EACvDH,OAA8B,EAC9BC,SAA6B;EAE7B,OAAOG,eAAA,CAAAC,kBAAA,CACLC,eAAA,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,OAAA,CAAG,MAAK;IACN;IACA2H,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,CAsBA,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;EACf,KAAK,QAAQ;CACjB;AACJ;AACA,SAAgB,aAAa,UAAU,SAAS,WAAW;CACvD,OAAO,IAAI,OAAO,oBAAoB,UAAU,SAAS,SAAS,CAAC;AACvE;AACA,SAAS,oBAAoB,UAAU,SAAS,WAAW;CACvD,OAAO,gBAAgB,mBAAmB,gBAAgB,KAAK,CAAC,UAAU,WAAW,cAAc,UAAU,OAAO,OAAO,GAAG,aAAa,QAAQ,CAAC,CAAC,gBAAgB,IAAI,gBAAgB,cAAc,aAAa,QAAQ,GAAG,aAAa,QAAQ,CAAC,CAAC,gBAAgB,QAAQ,UAAU,aAAa,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,WAAW,aAAa,UAAU,OAAO,SAAS,IAAI,CAAC,UAAU,WAAW,gBAAgB,SAAS,gBAAgB,SAAS,OAAO,aAAa,QAAQ,GAAG,aAAa,QAAQ,CAAC,CAAC,gBAAgB,cAAc;EAE3gB,SAAS,mBAAmB;EAC5B,IAAI,YAAY,YAAY,CAAC,SAAS,QAClC,SAAS,QAAQ;CAEzB,GAAG,aAAa,OAAO,CAAC,CAAC;AAC7B;AACA,SAAS,cAAc,UAAU,OAAO,SAAS;CAC7C,OAAO,gBAAgB,cAAc;EAEjC,SAAS,GAAG,kBAAkB;GAC1B,MAAM,OAAO,gBAAgB,WAAW,OAAO,aAAa,QAAQ;GACpE,IAAI,gB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,QAAQ,IAAI,KAAA;CAC/D,OAAO,iBAAiB,OAAO,gBAAgB,SAAS,WAAW,gBAAgB,OAAO,WAAW;EACjG,IAAI,SAAS,OAAO,MAAM,CAAC;EAC3B,IAAI,QAAQ;EAEZ,OAAO,KAAK,UAAU,QAAQ;GAC1B,OAAO,gBAAgB,QAAQ,UAAU,GAAG,GAAG,aAAa,SAAS,CAAC;EAC1E,CAAC;EAED,OAAO,KAAK,aAAa;GACrB,OAAO,gBAAgB,WAAW,QAAQ,aAAa,SAAS,CAAC;EACrE,CAAC;EAED,OAAO,GAAG,SAAS,UAAU;GACzB,SAAS,OAAO,OAAO,CAAC,QAAQ,KAAK,CAAC;GACtC,SAAS,MAAM;GACf,IAAI,YAAY,QAAQ,UACpB,OAAO,gBAAgB,QAAQ,0BAAU,IAAI,MAAM,mBAAmB,CAAC,GAAG,aAAa,SAAS,CAAC;EAEzG,CAAC;CACL,CAAC,GAAG,aAAa,SAAS,CAAC,CAAC,iBAAiB,qBAAqB,gBAAgB,QAAQ,UAAU,aAAa,SAAS,IAAI,WAAW,gBAAgB,cAAc;EAEnK,OAAO,mBAAmB;EAC1B,IAAI,YAAY,UAAU,CAAC,OAAO,QAC9B,OAAO,QAAQ;CAEvB,GAAG,aAAa,QAAQ,GAAG,aAAa,SAAS,CAAC,GAAG,aAAa,QAAQ;AAC9E"}
package/_mjs/stream.mjs CHANGED
@@ -1,3 +1 @@
1
- // codegen:start { preset: barrel, include: stream/*.ts }
2
- export * from "./stream/api.mjs";
3
- //# sourceMappingURL=stream.mjs.map
1
+ export { ReadableError, TransformError, fromReadable, fromWritable, fromWritableChannel, toString, toUint8Array, transform } from "./stream/api.mjs";
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
- extends Newtype<
10
- {
11
- readonly FileDescriptor: unique symbol;
12
- },
13
- number
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 {
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@fncts/node",
3
- "version": "0.0.44",
3
+ "version": "0.0.46",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/0x706b/fncts"
7
+ },
4
8
  "dependencies": {
5
- "@fncts/io": "0.0.51",
6
- "ws": "^8.20.0"
9
+ "ws": "^8.22.0",
10
+ "@fncts/io": "0.0.53"
7
11
  },
8
12
  "exports": {
9
13
  "./*": {
package/_cjs/fs.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"fs.cjs","names":["_api","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../_src/fs.ts"],"sourcesContent":[null],"mappings":";;;;;AACA,IAAAA,IAAA,gBAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,IAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,IAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,IAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"global.cjs","names":[],"sources":["../_src/global.ts"],"sourcesContent":[null],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../_src/index.ts"],"sourcesContent":[null],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.cjs","names":["_api","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../_src/stream.ts"],"sourcesContent":[null],"mappings":";;;;;AACA,IAAAA,IAAA,gBAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,IAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,IAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,IAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
package/_mjs/fs.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"fs.mjs","names":[],"sources":["../_src/fs.ts"],"sourcesContent":[null],"mappings":"AAAA;AACA,cAAc,cAAa","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"global.mjs","names":[],"sources":["../_src/global.ts"],"sourcesContent":[null],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../_src/index.ts"],"sourcesContent":[null],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.mjs","names":[],"sources":["../_src/stream.ts"],"sourcesContent":[null],"mappings":"AAAA;AACA,cAAc,kBAAiB","ignoreList":[]}