Socket
Socket
Sign inDemoInstall

get-caller-file

Package Overview
Dependencies
1
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 2.0.2

index.d.ts

36

index.js

@@ -1,3 +0,2 @@

'use strict';
"use strict";
// Call this function in a another function to find out the file from

@@ -7,19 +6,18 @@ // which that function was called from. (Inspects the v8 stack trace)

// Inspired by http://stackoverflow.com/questions/13227489
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;
// stack[0] holds this file
// stack[1] holds where this function was called
// stack[2] holds the file we're interested in
return stack[position] ? stack[position].getFileName() : undefined;
module.exports = function getCallerFile(position) {
if (position === void 0) { 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 + '`');
}
var oldPrepareStackTrace = Error.prepareStackTrace;
Error.prepareStackTrace = function (_, stack) { return stack; };
var stack = new Error().stack;
Error.prepareStackTrace = oldPrepareStackTrace;
if (stack !== null && typeof stack === 'object') {
// stack[0] holds this file
// stack[1] holds where this function was called
// stack[2] holds the file we're interested in
return stack[position] ? stack[position].getFileName() : undefined;
}
};
//# sourceMappingURL=index.js.map
{
"name": "get-caller-file",
"version": "2.0.1",
"version": "2.0.2",
"description": "",

@@ -10,5 +10,8 @@ "main": "index.js",

"files": [
"index.js"
"index.js",
"index.js.map",
"index.d.ts"
],
"scripts": {
"prepare": "tsc",
"test": "mocha test",

@@ -28,9 +31,16 @@ "test:debug": "mocha test"

"devDependencies": {
"@types/chai": "^4.1.7",
"@types/ensure-posix-path": "^1.0.0",
"@types/mocha": "^5.2.6",
"chai": "^4.1.2",
"ensure-posix-path": "^1.0.1",
"mocha": "^5.2.0"
"mocha": "^5.2.0",
"typescript": "^3.3.3333"
},
"engines": {
"node": "6.* || 8.* || >= 10.*"
},
"dependencies": {
"@types/node": "^11.10.5"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc