(object, depth)
| 2562 | return count; |
| 2563 | } |
| 2564 | encodeMap(object, depth) { |
| 2565 | const keys = Object.keys(object); |
| 2566 | if (this.sortKeys) { |
| 2567 | keys.sort(); |
| 2568 | } |
| 2569 | const size = this.ignoreUndefined ? this.countWithoutUndefined(object, keys) : keys.length; |
| 2570 | if (size < 16) { |
| 2571 | this.writeU8(0x80 + size); |
| 2572 | } else if (size < 0x10000) { |
| 2573 | this.writeU8(0xde); |
| 2574 | this.writeU16(size); |
| 2575 | } else if (size < 0x100000000) { |
| 2576 | this.writeU8(0xdf); |
| 2577 | this.writeU32(size); |
| 2578 | } else { |
| 2579 | throw new Error(`Too large map object: ${size}`); |
| 2580 | } |
| 2581 | for (const key of keys){ |
| 2582 | const value = object[key]; |
| 2583 | if (!(this.ignoreUndefined && value === undefined)) { |
| 2584 | this.encodeString(key); |
| 2585 | this.doEncode(value, depth + 1); |
| 2586 | } |
| 2587 | } |
| 2588 | } |
| 2589 | encodeExtension(ext) { |
| 2590 | const size = ext.data.length; |
| 2591 | if (size === 1) { |
no test coverage detected