版博士V2.0程序
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.

преди 1 година
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # stackback
  2. Returns an array of CallSite objects for a captured stacktrace. Useful if you want to access the frame for an error object.
  3. ## use
  4. ```javascript
  5. var stackback = require('stackback');
  6. // error generated from somewhere
  7. var err = new Error('some sample error');
  8. // stack is an array of CallSite objects
  9. var stack = stackback(err);
  10. ```
  11. ## CallSite object
  12. From the [V8 StackTrace API](https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi)
  13. The structured stack trace is an Array of CallSite objects, each of which represents a stack frame. A CallSite object defines the following methods
  14. getThis: returns the value of this
  15. getTypeName: returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property.
  16. getFunction: returns the current function
  17. getFunctionName: returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context.
  18. getMethodName: returns the name of the property of this or one of its prototypes that holds the current function
  19. getFileName: if this function was defined in a script returns the name of the script
  20. getLineNumber: if this function was defined in a script returns the current line number
  21. getColumnNumber: if this function was defined in a script returns the current column number
  22. getEvalOrigin: if this function was created using a call to eval returns a CallSite object representing the location where eval was called
  23. isToplevel: is this a toplevel invocation, that is, is this the global object?
  24. isEval: does this call take place in code defined by a call to eval?
  25. isNative: is this call in native V8 code?
  26. isConstructor: is this a constructor call?
  27. ## install
  28. ```shell
  29. npm install stackback
  30. ```