You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
631 B

4 years ago
  1. # callstack
  2. Access to v8's "raw" `CallSite`s.
  3. ## Installation
  4. $ npm install callsite
  5. ## Example
  6. ```js
  7. var stack = require('callsite');
  8. foo();
  9. function foo() {
  10. bar();
  11. }
  12. function bar() {
  13. baz();
  14. }
  15. function baz() {
  16. console.log();
  17. stack().forEach(function(site){
  18. console.log(' \033[36m%s\033[90m in %s:%d\033[0m'
  19. , site.getFunctionName() || 'anonymous'
  20. , site.getFileName()
  21. , site.getLineNumber());
  22. });
  23. console.log();
  24. }
  25. ```
  26. ## Why?
  27. Because you can do weird, stupid, clever, wacky things such as:
  28. - [better-assert](https://github.com/visionmedia/better-assert)
  29. ## License
  30. MIT