Skip to content

Commit 9bfc9bd

Browse files
committed
need ffi-types export
1 parent df12fdb commit 9bfc9bd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ts/ffi-types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,13 @@ export type QTS_C_To_HostInterruptFuncPointer = Pointer<'C_To_HostInterruptFunc'
5858
* for the Emscripten stack.
5959
*/
6060
export type HeapCharPointer = Pointer<'char'>
61+
62+
export function assertSync<Args extends any[], R>(fn: (...args: Args) => R): (...args: Args) => R {
63+
return function mustBeSync(...args: Args): R {
64+
const result = fn(...args)
65+
if (result && typeof result === 'object' && result instanceof Promise) {
66+
throw new Error('Function unexpectedly returned a Promise')
67+
}
68+
return result
69+
}
70+
}

0 commit comments

Comments
 (0)