CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
index.js22 linesDownload Raw Back to get-caller-file
1"use strict";2// Call this function in a another function to find out the file from3// which that function was called from. (Inspects the v8 stack trace)4//5// Inspired by http://stackoverflow.com/questions/132274896module.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 file17        // stack[1] holds where this function was called18        // stack[2] holds the file we're interested in19        return stack[position] ? stack[position].getFileName() : undefined;20    }21};22//# sourceMappingURL=index.js.map
basant307/AI_Governance_Project · CoolFace