INNER CODE UNIT · TypeScript
totalLength
backbone-hq/minibone · src/canonical.ts:53
const totalLength = elements.reduce((acc, el) => acc + el.length, 0)
if (totalLength > 4294967295) {
throw new Error('Array total encoded length exceeds 32-bit integer limit')
}
const header = new Uint8Array([0x20])
const length = new Uint8Array(new Uint32Array([elements.length]).buffer)
const elementsArray = Uint8Array.from(elements.flatMap((e) => Array.from(e)))
return new Uint8Array([...header, ...length, ...elementsArray])
}
throw new Error('Unsupported type')
}