# v8-callsites

> V8 stacktrace API callsites with knobs

Latest version **1.2.1** (published 2015-12-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install v8-callsites
pnpm add v8-callsites
yarn add v8-callsites
bun add v8-callsites
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2015-12-19 |
| First published | 2014-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/v8-callsites) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Javier Carrillo |
| Maintainers | stringparser |

## Links

- npm: https://www.npmjs.com/package/v8-callsites
- Repository: https://github.com/stringparser/v8-callsites
- Issues: https://github.com/stringparser/v8-callsites/issues
- npm.io page: https://npm.io/package/v8-callsites

## Recent versions

- 1.2.1 (latest) — 2015-12-19
- 1.2.0 — 2015-12-19
- 1.1.0 — 2014-10-10
- 1.0.35 — 2014-10-09
- 1.0.34 — 2014-10-09
- 1.0.33 — 2014-10-08
- 1.0.32 — 2014-10-04
- 1.0.31 — 2014-10-04
- 1.0.30 — 2014-09-25
- 1.0.28 — 2014-09-25
- 1.0.26 — 2014-09-24
- 1.0.24 — 2014-09-24
- 1.0.22 — 2014-09-23
- 1.0.20 — 2014-09-23
- 1.0.18 — 2014-09-23
- … 8 more at https://npm.io/package/v8-callsites/versions

## README

# v8-callsites [![NPM version][npm-badge]][npm-link] [![downloads][npm-downloads-badge]][npm-link]

[![build][travis-badge]][travis-link]

[V8 stacktrace API](https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi) callsites with knobs.

## install

    npm install --save v8-callsites

## usage

```js
var stack = require('v8-callsites');

origin();

function origin(){
  foo();
}

function foo(){
  bar();
}

function bar(){
  baz();
}

function baz(){

  var barStackFrombaz = stack(3, bar);
  // bar `stack` from baz with only 3 frames

  barstackFrombaz.forEach(function(frame){
    console.log(
      frame.getFunctionName(), '->', frame+''
    );
  });
}

```

### documentation

`require('v8-callsites')([frames, origin])`

 - `frames` if specified should be an `integer` bigger than `0` or `Infinity`.
 - `origin` if specified should be a function.
 - if no arguments, the default number of `frames` is `2` so the `origin` is the module itself. The returned stack is sliced by one.

See also the [avaliable methods](https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi) of the stack trace api like:
 - `getLineNumber`
 - `getFileName`
 - `getEvalOrigin`
 - etc.

## why

You would like to set how many frames are recorded (`Error.stackTraceLimit`) and from which function the stack should be traced back (`Error.captureStackTrace`).

By default two frames are recorded, though you can even lower it to one providing a function from which start.

### inspirated by

It serves for the same use cases implemented on this cool modules

 - [visionmedia `callsite`](https://github.com/visionmedia/callsite)
 - [sindresorhus `callsites`](https://github.com/sindresorhus/callsites)

I've been using those a lot.

## test

    npm test

### license

[![LICENSE](http://img.shields.io/npm/l/v8-callsites.svg?style=flat-square)](http://opensource.org/licenses/MIT)

<!-- links -->
[npm-link]: http://www.npmjs.org/package/v8-callsites
[npm-badge]: http://img.shields.io/npm/v/v8-callsites.svg?style=flat-square

[npm-downloads-badge]: http://img.shields.io/npm/dm/v8-callsites.svg?style=flat-square

[travis-link]: https://travis-ci.org/stringparser/v8-callsites/builds
[travis-badge]: http://img.shields.io/travis/stringparser/v8-callsites/master.svg?style=flat-square

---
_Source: https://npm.io/package/v8-callsites · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
