MCPcopy Index your code
hub / github.com/ether/etherpad / batch

Method batch

src/node/utils/Stream.ts:57–73  ·  view source on GitHub ↗

* Read values a chunk at a time from the underlying iterable. Once a full batch is read (or there * aren't enough values to make a full batch), all of the batch's values are yielded before the * next batch is read. * * This is useful for triggering groups of asynchronous tasks via Promis

(size: number)

Source from the content-addressed store, hash-verified

55 * @returns {Stream} A new Stream that gets its values from this Stream.
56 */
57 batch(size: number) {
58 return new Stream((function* () {
59 const b = [];
60 try {
61 // @ts-ignore
62 for (const v of this) {
63 Promise.resolve(v).catch(() => {}); // Suppress unhandled rejection errors.
64 b.push(v);
65 if (b.length < size) continue;
66 while (b.length) yield b.shift();
67 }
68 while (b.length) yield b.shift();
69 } finally {
70 for (const v of b) Promise.resolve(v).then(() => {}); // Un-suppress unhandled rejections.
71 }
72 }).call(this));
73 }
74
75 /**
76 * Pre-fetch a certain number of values from the underlying iterable before yielding the first

Callers 5

Stream.tsFile · 0.80
ExportEtherpad.tsFile · 0.80
ImportEtherpad.tsFile · 0.80
copyMethod · 0.80
checkMethod · 0.80

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected