Ohm-Management - Projektarbeit B-ME
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.

readme.md 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # callsites [![Build Status](https://travis-ci.org/sindresorhus/callsites.svg?branch=master)](https://travis-ci.org/sindresorhus/callsites)
  2. > Get callsites from the [V8 stack trace API](https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi)
  3. ## Install
  4. ```sh
  5. $ npm install --save callsites
  6. ```
  7. ## Usage
  8. ```js
  9. var callsites = require('callsites');
  10. function unicorn() {
  11. console.log(callsites()[0].getFileName());
  12. //=> /Users/sindresorhus/dev/callsites/test.js
  13. }
  14. unicorn();
  15. ```
  16. ## API
  17. Returns an array of callsite objects with the following methods:
  18. - `getThis`: returns the value of this
  19. - `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.
  20. - `getFunction`: returns the current function
  21. - `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.
  22. - `getMethodName`: returns the name of the property of this or one of its prototypes that holds the current function
  23. - `getFileName`: if this function was defined in a script returns the name of the script
  24. - `getLineNumber`: if this function was defined in a script returns the current line number
  25. - `getColumnNumber`: if this function was defined in a script returns the current column number
  26. - `getEvalOrigin`: if this function was created using a call to eval returns a CallSite object representing the location where eval was called
  27. - `isToplevel`: is this a toplevel invocation, that is, is this the global object?
  28. - `isEval`: does this call take place in code defined by a call to eval?
  29. - `isNative`: is this call in native V8 code?
  30. - `isConstructor`: is this a constructor call?
  31. ## License
  32. MIT © [Sindre Sorhus](http://sindresorhus.com)