UNPKG

typelorem

Version:

Lorem Ipsum generator for Typescript types

36 lines 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const assert = require("assert"); function caller(depth) { let pst = Error.prepareStackTrace; let stack; let file; let frame; let startIdx; pst = Error.prepareStackTrace; Error.prepareStackTrace = function (_, stack) { Error.prepareStackTrace = pst; return stack; }; stack = new Error().stack || []; startIdx = 0; while (startIdx < stack.length && stack[startIdx].getFileName() !== __filename) startIdx++; assert(startIdx < stack.length, "Unexpected: unable to find caller/index.js in the stack"); depth = !depth || isNaN(depth) ? 1 : depth > stack.length - 2 ? stack.length - 2 : depth; stack = stack.slice(startIdx + depth + 1); do { frame = stack.shift(); file = frame && frame.getFileName(); } while (stack.length && file === "module.js"); return file; } exports.default = caller; //# sourceMappingURL=caller.js.map