@lodestar/api
Version:
A Typescript REST client for the Ethereum Consensus API
10 lines • 661 B
JavaScript
import { MediaType } from "../headers.js";
export function addSszContentTypeParser(server) {
server.addContentTypeParser(MediaType.ssz, { parseAs: "buffer" }, async (_request, payload) => {
// We could just return the `Buffer` here which is a subclass of `Uint8Array` but downstream code does not require it
// and it's better to convert it here to avoid unexpected behavior such as `Buffer.prototype.slice` not copying memory
// See https://github.com/nodejs/node/issues/41588#issuecomment-1016269584
return new Uint8Array(payload.buffer, payload.byteOffset, payload.byteLength);
});
}
//# sourceMappingURL=parser.js.map