MCPcopy
hub / github.com/yume-chan/ya-webadb / push

Method push

libraries/stream-extra/src/distribution.ts:28–68  ·  view source on GitHub ↗

* Pushes data to the combiner. * @param data The input data to be split or combined. * @returns * A generator that yields buffers of specified size. * It may yield the same buffer multiple times, consume the data before calling `next`.

(data: Uint8Array)

Source from the content-addressed store, hash-verified

26 * It may yield the same buffer multiple times, consume the data before calling `next`.
27 */
28 *push(data: Uint8Array): Generator<Uint8Array, void, void> {
29 let offset = 0;
30 let available = data.length;
31
32 if (this.#offset !== 0) {
33 if (available >= this.#available) {
34 this.#buffer.set(
35 data.subarray(0, this.#available),
36 this.#offset,
37 );
38 offset += this.#available;
39 available -= this.#available;
40
41 yield this.#buffer;
42 this.#offset = 0;
43 this.#available = this.#capacity;
44
45 if (available === 0) {
46 return;
47 }
48 } else {
49 this.#buffer.set(data, this.#offset);
50 this.#offset += available;
51 this.#available -= available;
52 return;
53 }
54 }
55
56 while (available >= this.#capacity) {
57 const end = offset + this.#capacity;
58 yield data.subarray(offset, end);
59 offset = end;
60 available -= this.#capacity;
61 }
62
63 if (available > 0) {
64 this.#buffer.set(data.subarray(offset), this.#offset);
65 this.#offset += available;
66 this.#available -= available;
67 }
68 }
69
70 flush(): Uint8Array | undefined {
71 if (this.#offset === 0) {

Callers 15

writeMethod · 0.80
getEncodersFunction · 0.80
getEncodersFunction · 0.80
getDisplaysFunction · 0.80
getLogSizeMethod · 0.80
clearMethod · 0.80
binaryMethod · 0.80
setMethod · 0.80
parseFunction · 0.80
buildArgumentsFunction · 0.80
buildInstallArgumentsFunction · 0.80
installMethod · 0.80

Calls 1

setMethod · 0.80

Tested by 1

runTestFunction · 0.64