UNPKG

foxts

Version:

Opinionated collection of common TypeScript utils by @SukkaW

1 lines 432 B
const t="name",r="message",n="stack";function e(e){return"object"==typeof e&&!!e&&t in e&&"string"==typeof e[t]&&r in e&&"string"==typeof e[r]&&(!(n in e)||"string"==typeof e[n])}function i(s,o=!0,f=!1){if(!e(s))return null;let c="";if(o&&(c+=s[t],c+=": "),c+=s[r],f&&n in s&&"string"==typeof s[n]){const r=s[n];if(r.startsWith(s[t]))return r.trim();c+="\n"+r}return c.trim()}export{i as extractErrorMessage,e as isErrorLikeObject};