(batch)
| 1031 | // Returns undefined on sync success, or a Promise when async fallback |
| 1032 | // is required. Callers must check: const p = writeBatch(b); if (p) await p; |
| 1033 | function writeBatch(batch) { |
| 1034 | if (hasWritev && batch.length > 1) { |
| 1035 | if (!hasWritevSync || !writer.writevSync(batch)) { |
| 1036 | const opts = signal ? { __proto__: null, signal } : undefined; |
| 1037 | const writevResult = writer.writev(batch, opts); |
| 1038 | if (writevResult === undefined) { |
| 1039 | for (let i = 0; i < batch.length; i++) { |
| 1040 | totalBytes += TypedArrayPrototypeGetByteLength(batch[i]); |
| 1041 | } |
| 1042 | return; |
| 1043 | } |
| 1044 | return PromisePrototypeThen(PromiseResolve(writevResult), () => { |
| 1045 | for (let i = 0; i < batch.length; i++) { |
| 1046 | totalBytes += TypedArrayPrototypeGetByteLength(batch[i]); |
| 1047 | } |
| 1048 | }); |
| 1049 | } |
| 1050 | for (let i = 0; i < batch.length; i++) { |
| 1051 | totalBytes += TypedArrayPrototypeGetByteLength(batch[i]); |
| 1052 | } |
| 1053 | return; |
| 1054 | } |
| 1055 | for (let i = 0; i < batch.length; i++) { |
| 1056 | const chunk = batch[i]; |
| 1057 | if (!hasWriteSync || !writer.writeSync(chunk)) { |
| 1058 | // Sync path failed at index i - fall back to async for the rest. |
| 1059 | return writeBatchAsyncFallback(batch, i); |
| 1060 | } |
| 1061 | totalBytes += TypedArrayPrototypeGetByteLength(chunk); |
| 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | try { |
| 1066 | if (useSyncIterableFastPath) { |
no test coverage detected