in statefun-sdk-js/src/types.ts [47:65]
static parseTypedValue<T>(
box: proto.io.statefun.sdk.reqreply.TypedValue | undefined | null,
type: Type<T>
): T | null {
if (type === undefined || type === null) {
throw new Error("Type can not be missing");
}
if (box === undefined || box === null) {
return null;
}
if (!box.getHasValue()) {
return null;
}
if (box.getTypename() !== type.typename) {
throw new Error(`Type mismatch: ${box.getTypename()} is not of type ${type.typename}`);
}
const buf = Buffer.from(box.getValue_asU8());
return type.deserialize(buf);
}