MCPcopy
hub / github.com/lowlighter/metrics / encodeMap

Method encodeMap

source/plugins/community/splatoon/s3si/index.ts:2564–2588  ·  view source on GitHub ↗
(object, depth)

Source from the content-addressed store, hash-verified

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) {

Callers 1

encodeObjectMethod · 0.95

Calls 6

countWithoutUndefinedMethod · 0.95
writeU8Method · 0.95
writeU16Method · 0.95
writeU32Method · 0.95
encodeStringMethod · 0.95
doEncodeMethod · 0.95

Tested by

no test coverage detected