MCPcopy Create free account
hub / github.com/WinterTC55/iter-streams / processTransformResultSync

Function processTransformResultSync

src/pull.js:285–319  ·  view source on GitHub ↗

* Process transform result (sync).

(result)

Source from the content-addressed store, hash-verified

283 * Process transform result (sync).
284 */
285function processTransformResultSync(result) {
286 var batch, _i, result_1, item, _a, _b, chunk;
287 return __generator(this, function (_c) {
288 switch (_c.label) {
289 case 0:
290 if (result === null) {
291 return [2 /*return*/];
292 }
293 if (!(Array.isArray(result) && result.length > 0 && result[0] instanceof Uint8Array)) return [3 /*break*/, 3];
294 if (!(result.length > 0)) return [3 /*break*/, 2];
295 return [4 /*yield*/, result];
296 case 1:
297 _c.sent();
298 _c.label = 2;
299 case 2: return [2 /*return*/];
300 case 3:
301 if (!(0, from_js_1.isSyncIterable)(result)) return [3 /*break*/, 6];
302 batch = [];
303 for (_i = 0, result_1 = result; _i < result_1.length; _i++) {
304 item = result_1[_i];
305 for (_a = 0, _b = flattenTransformYieldSync(item); _a < _b.length; _a++) {
306 chunk = _b[_a];
307 batch.push(chunk);
308 }
309 }
310 if (!(batch.length > 0)) return [3 /*break*/, 5];
311 return [4 /*yield*/, batch];
312 case 4:
313 _c.sent();
314 _c.label = 5;
315 case 5: return [2 /*return*/];
316 case 6: throw new TypeError("Invalid transform result type");
317 }
318 });
319}
320/**
321 * Process transform result (async).
322 */

Callers 1

Calls 2

pushMethod · 0.65

Tested by

no test coverage detected