index.d.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. declare namespace cleanStack {
  2. interface Options {
  3. /**
  4. Prettify the file paths in the stack:
  5. `/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15` → `~/dev/clean-stack/unicorn.js:2:15`
  6. @default false
  7. */
  8. readonly pretty?: boolean;
  9. }
  10. }
  11. /**
  12. Clean up error stack traces. Removes the mostly unhelpful internal Node.js entries.
  13. @param stack - The `stack` property of an `Error`.
  14. @example
  15. ```
  16. import cleanStack = require('clean-stack');
  17. const error = new Error('Missing unicorn');
  18. console.log(error.stack);
  19. // Error: Missing unicorn
  20. // at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
  21. // at Module._compile (module.js:409:26)
  22. // at Object.Module._extensions..js (module.js:416:10)
  23. // at Module.load (module.js:343:32)
  24. // at Function.Module._load (module.js:300:12)
  25. // at Function.Module.runMain (module.js:441:10)
  26. // at startup (node.js:139:18)
  27. console.log(cleanStack(error.stack));
  28. // Error: Missing unicorn
  29. // at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
  30. ```
  31. */
  32. declare function cleanStack(
  33. stack: string,
  34. options?: cleanStack.Options
  35. ): string;
  36. export = cleanStack;