get-caller-file
Advanced tools
Comparing version 1.0.3 to 2.0.0
14
index.js
@@ -8,9 +8,13 @@ 'use strict'; | ||
module.exports = function getCallerFile(_position) { | ||
var oldPrepareStackTrace = Error.prepareStackTrace; | ||
Error.prepareStackTrace = function(err, stack) { return stack; }; | ||
var stack = new Error().stack; | ||
module.exports = function getCallerFile(position = 2) { | ||
if (position >= Error.stackTraceLimit) { | ||
throw new TypeError('getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `' + position + '` and Error.stackTraceLimit was: `' + Error.stackTraceLimit + '`'); | ||
} | ||
const oldPrepareStackTrace = Error.prepareStackTrace; | ||
Error.prepareStackTrace = (err, stack) => stack; | ||
const stack = new Error().stack; | ||
Error.prepareStackTrace = oldPrepareStackTrace; | ||
var position = _position ? _position : 2; | ||
@@ -17,0 +21,0 @@ // stack[0] holds this file |
{ | ||
"name": "get-caller-file", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "", | ||
@@ -30,3 +30,6 @@ "main": "index.js", | ||
"mocha": "^5.2.0" | ||
}, | ||
"engines": { | ||
"node": "6.* || 8.* || >= 10.*" | ||
} | ||
} |
2736
18