what-line-is-this

2.0.0 • Public • Published

what-line-is-this

Output a message prefixed with the name and line number of the source file where you outputted the message

npm install what-line-is-this

build status

Usage

Assuming the following file is saved as /Users/maf/index.js

var what = require('what-line-is-this')
 
var foo = function () {
  what('line is this?')
}
 
what('line is this?')
foo()

Running it will produce the following output

/Users/maf/index.js:4 - line is this?
/Users/maf/index.js:7 - line is this?

If you wanted to output the line of the calling method instead use what.stack(pos) to change the stack frame being used.

var what = require('what-line-is-this').stack(1)
 
var foo = function() {
  what('line is this?')
}
 
foo()

Running the above will print

/Users/maf/index.js:7 - line is this?

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i what-line-is-this

Weekly Downloads

0

Version

2.0.0

License

MIT

Unpacked Size

3.98 kB

Total Files

7

Last publish

Collaborators

  • mafintosh