source: trip-planner-front/node_modules/callsites/readme.md@ 6fe77af

Last change on this file since 6fe77af was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[6a3a178]1# callsites [![Build Status](https://travis-ci.org/sindresorhus/callsites.svg?branch=master)](https://travis-ci.org/sindresorhus/callsites)
2
3> Get callsites from the [V8 stack trace API](https://v8.dev/docs/stack-trace-api)
4
5
6## Install
7
8```
9$ npm install callsites
10```
11
12
13## Usage
14
15```js
16const callsites = require('callsites');
17
18function unicorn() {
19 console.log(callsites()[0].getFileName());
20 //=> '/Users/sindresorhus/dev/callsites/test.js'
21}
22
23unicorn();
24```
25
26
27## API
28
29Returns an array of callsite objects with the following methods:
30
31- `getThis`: returns the value of `this`.
32- `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.
33- `getFunction`: returns the current function.
34- `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.
35- `getMethodName`: returns the name of the property of `this` or one of its prototypes that holds the current function.
36- `getFileName`: if this function was defined in a script returns the name of the script.
37- `getLineNumber`: if this function was defined in a script returns the current line number.
38- `getColumnNumber`: if this function was defined in a script returns the current column number
39- `getEvalOrigin`: if this function was created using a call to `eval` returns a string representing the location where `eval` was called.
40- `isToplevel`: is this a top-level invocation, that is, is this the global object?
41- `isEval`: does this call take place in code defined by a call to `eval`?
42- `isNative`: is this call in native V8 code?
43- `isConstructor`: is this a constructor call?
44
45
46## License
47
48MIT © [Sindre Sorhus](https://sindresorhus.com)
Note: See TracBrowser for help on using the repository browser.