MCPcopy Create free account
hub / github.com/btd/rollup-plugin-visualizer / vector

Method vector

shared/share/binary.ts:71–94  ·  view source on GitHub ↗
(values: readonly number[], delta = false)

Source from the content-addressed store, hash-verified

69 }
70
71 vector(values: readonly number[], delta = false): void {
72 budget(values.length, this.limits.maxEntries, "Vector count");
73 this.uint(values.length);
74 if (!values.length) return;
75 if (delta) {
76 let previous = 0;
77 for (const n of values) {
78 uint(n);
79 const d = n - previous;
80 previous = n;
81 if (!Number.isSafeInteger(d < 0 ? -2 * d - 1 : 2 * d)) {
82 delta = false;
83 break;
84 }
85 }
86 }
87 this.uint(delta ? 1 : 0);
88 let previous = 0;
89 for (const n of values) {
90 const d = n - previous;
91 previous = n;
92 this.uint(delta ? (d < 0 ? -2 * d - 1 : 2 * d) : n);
93 }
94 }
95
96 finish(): Uint8Array {
97 return this.buffer.slice(0, this.position);

Callers 9

encodeReportFunction · 0.95
writeUidsFunction · 0.45
readUidsFunction · 0.45
writeStringsFunction · 0.45
readStringsFunction · 0.45
linksFunction · 0.45
readTreeFunction · 0.45
readLinksFunction · 0.45

Calls 3

uintMethod · 0.95
budgetFunction · 0.85
uintFunction · 0.85

Tested by

no test coverage detected