MCPcopy Create free account
hub / github.com/mapbox/pbf / writeRawMessage

Method writeRawMessage

index.js:373–387  ·  view source on GitHub ↗

* @template T * @param {(obj: T, pbf: PbfWriter) => void} fn * @param {T} obj

(fn, obj)

Source from the content-addressed store, hash-verified

371 * @param {T} obj
372 */
373 writeRawMessage(fn, obj) {
374 this.pos++; // reserve 1 byte for short message length
375
376 // write the message directly to the buffer and see how much was written
377 const startPos = this.pos;
378 fn(obj, this);
379 const len = this.pos - startPos;
380
381 if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
382
383 // finally, write the message length in the reserved place and restore the position
384 this.pos = startPos - 1;
385 this.writeVarint(len);
386 this.pos += len;
387 }
388
389 /**
390 * @template T

Callers 2

writeMessageMethod · 0.95
pbf.test.jsFile · 0.80

Calls 2

writeVarintMethod · 0.95
makeRoomForExtraLengthFunction · 0.85

Tested by

no test coverage detected