source: trip-planner-front/node_modules/get-caller-file/index.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1"use strict";
2// Call this function in a another function to find out the file from
3// which that function was called from. (Inspects the v8 stack trace)
4//
5// Inspired by http://stackoverflow.com/questions/13227489
6module.exports = function getCallerFile(position) {
7 if (position === void 0) { position = 2; }
8 if (position >= Error.stackTraceLimit) {
9 throw new TypeError('getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `' + position + '` and Error.stackTraceLimit was: `' + Error.stackTraceLimit + '`');
10 }
11 var oldPrepareStackTrace = Error.prepareStackTrace;
12 Error.prepareStackTrace = function (_, stack) { return stack; };
13 var stack = new Error().stack;
14 Error.prepareStackTrace = oldPrepareStackTrace;
15 if (stack !== null && typeof stack === 'object') {
16 // stack[0] holds this file
17 // stack[1] holds where this function was called
18 // stack[2] holds the file we're interested in
19 return stack[position] ? stack[position].getFileName() : undefined;
20 }
21};
22//# sourceMappingURL=index.js.map
Note: See TracBrowser for help on using the repository browser.