MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / set

Method set

projects/JavaScript/proto/fbe.js:4585–4601  ·  view source on GitHub ↗

* Set the optional value * @this {!FinalModelOptional} * @param {object} optional Optional value * @returns {!number} Final model size

(optional)

Source from the content-addressed store, hash-verified

4583 * @returns {!number} Final model size
4584 */
4585 set (optional) {
4586 console.assert(((this._buffer.offset + this.fbeOffset + 1) <= this._buffer.size), 'Model is broken!')
4587 if ((this._buffer.offset + this.fbeOffset + 1) > this._buffer.size) {
4588 return 0
4589 }
4590
4591 let hasValue = (optional != null)
4592 this.writeUInt8(this.fbeOffset, (hasValue ? 1 : 0))
4593 if (!hasValue) {
4594 return 1
4595 }
4596
4597 this._buffer.shift(this.fbeOffset + 1)
4598 let size = this.value.set(optional)
4599 this._buffer.unshift(this.fbeOffset + 1)
4600 return 1 + size
4601 }
4602}
4603
4604exports.FinalModelOptional = FinalModelOptional

Callers

nothing calls this directly

Calls 4

writeUInt8Method · 0.80
shiftMethod · 0.45
setMethod · 0.45
unshiftMethod · 0.45

Tested by

no test coverage detected