yhtml5-test
Version:
A test framework for front-end projects
41 lines (36 loc) • 1.52 kB
JavaScript
import { parse } from './parser'; /**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { map } from './mapper';
import { unmap } from './unmapper';
function getStackFrames(error) {
var unhandledRejection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var contextSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
var parsedFrames = parse(error);
var enhancedFramesPromise = void 0;
if (error.__unmap_source) {
enhancedFramesPromise = unmap(
// $FlowFixMe
error.__unmap_source, parsedFrames, contextSize);
} else {
enhancedFramesPromise = map(parsedFrames, contextSize);
}
return enhancedFramesPromise.then(function (enhancedFrames) {
if (enhancedFrames.map(function (f) {
return f._originalFileName;
}).filter(function (f) {
return f != null && f.indexOf('node_modules') === -1;
}).length === 0) {
return null;
}
return enhancedFrames.filter(function (_ref) {
var functionName = _ref.functionName;
return functionName == null || functionName.indexOf('__stack_frame_overlay_proxy_console__') === -1;
});
});
}
export default getStackFrames;
export { getStackFrames };