piral-debug-utils
Version:
Utilities for debugging Piral instances.
22 lines • 754 B
JavaScript
let installPromise;
export function install() {
if (!installPromise) {
installPromise = new Promise((resolve, reject) => {
const sts = document.createElement('script');
sts.src = 'https://cdnjs.cloudflare.com/ajax/libs/stacktrace.js/2.0.2/stacktrace.min.js';
document.head.appendChild(sts);
sts.onload = () => resolve();
sts.onerror = () => reject();
});
}
return installPromise;
}
export async function convertError(error, start = 0, end = -1) {
await install();
const frames = await window.StackTrace.fromError(error);
return frames
.slice(start, end)
.map((sf) => sf.toString())
.join('\n');
}
//# sourceMappingURL=stack.js.map