* Parse a field and return the Object read from the record * * @private * @returns {Object}
()
| 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 |