stack-infos

1.1.0 • Public • Published

Stack-infos

Get informations about each function in the stack.

Installation

npm install stack-infos

Usage

var stack = require('stack-infos');
function test() {
	stack();
}

It will return an object which look like this :

{
	file: '/home/Emeraude/node_modules/stack-infos/test.js',
	dir: '/home/Emeraude/node_modules/stack-infos',
	function: 'test',
	line: 3,
	column: 2
}

Note that it can take an int as parameter than represent the level of the stack. 0 is the last function, 1 is the function that call it.

You can also get it as a string

function test() {
	stack.string(0); // returns 'test (/home/Emeraude/node_modules/stack-infos/test.js:3:2)'
	stack.string(1); // returns 'null (/home/Emeraude/node_modules/stack-infos/test.js:1:1)'
}

You can also get the full stack in an array of objects similar to stack()

function test() {
	stack.full(); // returns an array of objects
	stack.size(); // return the size of the full stack
}

Author

Emeraude

Package Sidebar

Install

npm i stack-infos

Weekly Downloads

4

Version

1.1.0

License

GPL-3.0

Last publish

Collaborators

  • emeraude