Mercurial > code > home > repos > light9
view web/lib/avro.ts @ 2447:361c612e3c60
checkpoint show data
author | drewp@bigasterisk.com |
---|---|
date | Mon, 03 Jun 2024 12:11:54 -0700 |
parents | ef3cde3e81e8 |
children |
line wrap: on
line source
import * as avrojs from "avro-js"; export namespace avro { export async function loadType(typeName: string): Promise<avrojs.types.Type> { const schemaSource = await (await fetch(`/avro/${typeName}.avsc`)).json(); return await avrojs.parse(schemaSource); } export async function parseBlob(type: avrojs.types.Type, b: Blob): Promise<avrojs.types.Record> { const jsMsg = type.fromBuffer(Buffer.from(await b.arrayBuffer())); return jsMsg; } }