massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / clear-error-stack.js
1 var uncurryThis = require('../internals/function-uncurry-this');
2 var arraySlice = require('../internals/array-slice-simple');
3
4 var replace = uncurryThis(''.replace);
5 var split = uncurryThis(''.split);
6 var join = uncurryThis([].join);
7
8 var TEST = (function (arg) { return String(Error(arg).stack); })('zxcasd');
9 var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
10 var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
11 var IS_FIREFOX_OR_SAFARI_STACK = /@[^\n]*\n/.test(TEST) && !/zxcasd/.test(TEST);
12
13 module.exports = function (stack, dropEntries) {
14   if (typeof stack != 'string') return stack;
15   if (IS_V8_OR_CHAKRA_STACK) {
16     while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
17   } else if (IS_FIREFOX_OR_SAFARI_STACK) {
18     return join(arraySlice(split(stack, '\n'), dropEntries), '\n');
19   } return stack;
20 };