starpc 0.23.1 → 0.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/srpc/pushable.js +15 -9
- package/package.json +1 -1
- package/srpc/pushable.ts +14 -9
package/dist/srpc/pushable.js
CHANGED
|
@@ -13,17 +13,23 @@ export async function writeToPushable(dataSource, out) {
|
|
|
13
13
|
}
|
|
14
14
|
export function buildPushableSink(target) {
|
|
15
15
|
return async (source) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
try {
|
|
17
|
+
if (Symbol.asyncIterator in source) {
|
|
18
|
+
// Handle AsyncIterable
|
|
19
|
+
for await (const pkt of source) {
|
|
20
|
+
processPacket(pkt, target);
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
else {
|
|
24
|
+
// Handle Iterable
|
|
25
|
+
for (const pkt of source) {
|
|
26
|
+
processPacket(pkt, target);
|
|
27
|
+
}
|
|
26
28
|
}
|
|
29
|
+
target.end();
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
target.end(err);
|
|
27
33
|
}
|
|
28
34
|
};
|
|
29
35
|
}
|
package/package.json
CHANGED
package/srpc/pushable.ts
CHANGED
|
@@ -21,16 +21,21 @@ export function buildPushableSink<T>(
|
|
|
21
21
|
target: Pushable<T>,
|
|
22
22
|
): Sink<Source<T>, Promise<void>> {
|
|
23
23
|
return async (source: Source<T>): Promise<void> => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
try {
|
|
25
|
+
if (Symbol.asyncIterator in source) {
|
|
26
|
+
// Handle AsyncIterable
|
|
27
|
+
for await (const pkt of source as AsyncIterable<any>) {
|
|
28
|
+
processPacket(pkt, target)
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
// Handle Iterable
|
|
32
|
+
for (const pkt of source as Iterable<any>) {
|
|
33
|
+
processPacket(pkt, target)
|
|
34
|
+
}
|
|
33
35
|
}
|
|
36
|
+
target.end()
|
|
37
|
+
} catch (err) {
|
|
38
|
+
target.end(err as Error)
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
}
|