MCPcopy
hub / github.com/gchq/CyberChef / _parseField

Method _parseField

src/core/lib/Protobuf.mjs:409–436  ·  view source on GitHub ↗

* Parse a field and return the Object read from the record * * @private * @returns {Object}

()

Source from the content-addressed store, hash-verified

407 * @returns {Object}
408 */
409 _parseField() {
410 // Get the field headers
411 const header = this._fieldHeader();
412 const type = header.type;
413 const key = header.key;
414
415 if (typeof(this.fieldTypes[key]) !== "object") {
416 this.fieldTypes[key] = type;
417 }
418
419 switch (type) {
420 // varint
421 case 0:
422 return { "key": key, "value": this._varInt() };
423 // fixed 64
424 case 1:
425 return { "key": key, "value": this._uint64() };
426 // length delimited
427 case 2:
428 return { "key": key, "value": this._lenDelim(key) };
429 // fixed 32
430 case 5:
431 return { "key": key, "value": this._uint32() };
432 // unknown type
433 default:
434 throw new Error("Unknown type 0x" + type.toString(16));
435 }
436 }
437
438 /**
439 * Parse the field header and return the type and key

Callers 1

_parseMethod · 0.95

Calls 6

_fieldHeaderMethod · 0.95
_varIntMethod · 0.95
_uint64Method · 0.95
_lenDelimMethod · 0.95
_uint32Method · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected