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

Method get

projects/JavaScript/proto/fbe.js:4563–4577  ·  view source on GitHub ↗

* Get the optional value * @this {!FinalModelOptional} * @returns {!object} Result optional value and its size

()

Source from the content-addressed store, hash-verified

4561 * @returns {!object} Result optional value and its size
4562 */
4563 get () {
4564 console.assert(((this._buffer.offset + this.fbeOffset + 1) <= this._buffer.size), 'Model is broken!')
4565 if ((this._buffer.offset + this.fbeOffset + 1) > this._buffer.size) {
4566 return { value: undefined, size: 0 }
4567 }
4568
4569 if (!this.hasValue) {
4570 return { value: undefined, size: 1 }
4571 }
4572
4573 this._buffer.shift(this.fbeOffset + 1)
4574 let optional = this.value.get()
4575 this._buffer.unshift(this.fbeOffset + 1)
4576 return { value: optional.value, size: (1 + optional.size) }
4577 }
4578
4579 /**
4580 * Set the optional value

Callers

nothing calls this directly

Calls 3

shiftMethod · 0.45
getMethod · 0.45
unshiftMethod · 0.45

Tested by

no test coverage detected