MCPcopy Index your code
hub / github.com/tensorflow/tfjs / pump

Method pump

tfjs-data/src/iterators/string_iterator.ts:86–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

84 }
85
86 async pump(): Promise<boolean> {
87 const chunkResult = await this.upstream.next();
88 if (chunkResult.done) {
89 if (this.carryover === '') {
90 return false;
91 }
92
93 // Pretend that the pump succeeded in order to emit the small last batch.
94 // The next pump() call will actually fail.
95 this.outputQueue.push(this.carryover);
96 this.carryover = '';
97 return true;
98 }
99 const lines = chunkResult.value.split(this.separator) as string[];
100 // Note the behavior: " ab ".split(' ') === ['', 'ab', '']
101 // Thus the carryover may be '' if the separator falls on a chunk
102 // boundary; this produces the correct result.
103
104 lines[0] = this.carryover + lines[0];
105 for (const line of lines.slice(0, -1)) {
106 this.outputQueue.push(line);
107 }
108 this.carryover = lines[lines.length - 1];
109
110 return true;
111 }
112}

Callers

nothing calls this directly

Calls 4

splitMethod · 0.65
sliceMethod · 0.65
nextMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected