export function decode<T>(ptr: Deno.PointerValue): T {
if (!ptr) throw new Error("tried to decode null ptr: " + ptr);
// ptr is a cstring
const cstr = new Deno.UnsafePointerView(ptr).getCString();
return JSON.parse(cstr);
}
but I want to hoist the ptr check outside of the function, but PointerObject is not exposed
// deno-lint-ignore no-explicit-any
export function decode<T>(ptr: any /*Deno.PointerObject*/): T {
// ptr is a cstring
const cstr = new Deno.UnsafePointerView(ptr).getCString();
return JSON.parse(cstr);
}
I have a function like this
but I want to hoist the ptr check outside of the function, but PointerObject is not exposed