MCPcopy Create free account
hub / github.com/denoland/celld / write

Method write

crates/celld/js/node_stream.js:42–58  ·  view source on GitHub ↗
(buf)

Source from the content-addressed store, hash-verified

40 }
41 }
42 write(buf) {
43 if (typeof buf === "string") return buf;
44 const u8 = buf instanceof Uint8Array
45 ? buf : new Uint8Array(buf.buffer ?? buf);
46 if (this.__td) return this.__td.decode(u8, { stream: true });
47 let bytes = u8;
48 if (this.__rem !== undefined) {
49 const joined = this.__rem
50 ? Buffer.concat([this.__rem, u8]) : Buffer.from(u8);
51 const keep = joined.length % 3;
52 this.__rem = keep ? joined.slice(joined.length - keep) : null;
53 bytes = joined.slice(0, joined.length - keep);
54 }
55 return Buffer.from(
56 bytes.buffer, bytes.byteOffset, bytes.byteLength,
57 ).toString(this.encoding);
58 }
59 end(buf) {
60 let out = buf !== undefined && buf.length ? this.write(buf) : "";
61 if (this.__td) out += this.__td.decode();

Callers 9

endMethod · 0.95
textMethod · 0.95
ondataFunction · 0.45
readableAddChunkFunction · 0.45
_duplexifyFunction · 0.45
pumpFunction · 0.45
pipelineImplFunction · 0.45

Calls 5

decodeMethod · 0.80
concatMethod · 0.45
fromMethod · 0.45
sliceMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected