Rocky_Mountain_Vending/.pnpm-store/v10/files/92/24922a7e5d2c3f564e6e730759f82bdd21a7e70d7702b7bf26c64fb41319b440a764feecdb6c481041acc568900467df84a49ac3627574326cc3e7898da73f
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

47 lines
1.9 KiB
Text

export function getUnmarshalledStream(source, options) {
const messageUnmarshaller = getMessageUnmarshaller(options.deserializer, options.toUtf8);
return {
[Symbol.asyncIterator]: async function* () {
for await (const chunk of source) {
const message = options.eventStreamCodec.decode(chunk);
const type = await messageUnmarshaller(message);
if (type === undefined)
continue;
yield type;
}
},
};
}
export function getMessageUnmarshaller(deserializer, toUtf8) {
return async function (message) {
const { value: messageType } = message.headers[":message-type"];
if (messageType === "error") {
const unmodeledError = new Error(message.headers[":error-message"].value || "UnknownError");
unmodeledError.name = message.headers[":error-code"].value;
throw unmodeledError;
}
else if (messageType === "exception") {
const code = message.headers[":exception-type"].value;
const exception = { [code]: message };
const deserializedException = await deserializer(exception);
if (deserializedException.$unknown) {
const error = new Error(toUtf8(message.body));
error.name = code;
throw error;
}
throw deserializedException[code];
}
else if (messageType === "event") {
const event = {
[message.headers[":event-type"].value]: message,
};
const deserialized = await deserializer(event);
if (deserialized.$unknown)
return;
return deserialized;
}
else {
throw Error(`Unrecognizable event type: ${message.headers[":event-type"].value}`);
}
};
}