mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: type errors in definitions
This commit is contained in:
1 parent
3e18d5a8db
commit
61fe8c7e7c
22 files changed
+1728
-1692
No files matched your search
@@ -0,0 +1,5 @@
|
||||
import { MessageFns } from '../protos';
|
||||
|
||||
export function encodePB64<Type>(message: MessageFns<Type>, data: Type) {
|
||||
return Buffer.from(message.encode(data).finish()).toString('base64');
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { MessageFns } from '../protos';
|
||||
|
||||
export async function fetchPB<Type>(url: string, message: MessageFns<Type>) {
|
||||
const response = await fetch(url);
|
||||
const buffer = await response.arrayBuffer();
|
||||
const array = new Uint8Array(buffer);
|
||||
return message.decode(array);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './encodePB64';
|
||||
export * from './fetchPB';
|
||||
export * from './pbMap';
|
||||
@@ -0,0 +1 @@
|
||||
export type PBMap<T> = T[keyof T] extends number ? T[keyof T] : never;
|
||||
Reference in new issue
Block a user