Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-stack-trace

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-stack-trace - npm Package Compare versions

Comparing version 2.0.3 to 2.1.0

performance/benchmark.js

6

dist/getStackTrace.js

@@ -18,5 +18,5 @@ "use strict";

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

@@ -44,3 +44,3 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

return _objectSpread({}, (0, _materializeCallSite.default)(callSite), {}, (await (0, _resolveCallSiteSourceCodeLocation.default)(callSite)));
return _objectSpread(_objectSpread({}, (0, _materializeCallSite.default)(callSite)), await (0, _resolveCallSiteSourceCodeLocation.default)(callSite));
});

@@ -47,0 +47,0 @@ };

@@ -12,10 +12,23 @@ "use strict";

const fileAccessCache = {};
const isReadableFile = filePath => {
// If the file was previously unreadable, we can assume this
// will always be the case
let accessable = fileAccessCache[filePath];
if (accessable !== undefined) {
return accessable;
}
try {
_fs.default.accessSync(filePath, _fs.default.constants.R_OK);
return true;
accessable = true;
} catch (error) {
return false;
accessable = false;
}
fileAccessCache[filePath] = accessable;
return accessable;
};

@@ -22,0 +35,0 @@

@@ -10,2 +10,4 @@ "use strict";

var _util = require("util");
var _path = _interopRequireDefault(require("path"));

@@ -21,2 +23,28 @@

const readFile = (0, _util.promisify)(_fs.default.readFile);
const cachedOriginalLines = {};
const resolveOriginalPosition = (mapFilePath, column, line) => {
const lineKey = `${mapFilePath}-${line}-${column}`; // if possible, attempt to resolve the original lines from cache
let originalLineResult = cachedOriginalLines[lineKey];
if (!originalLineResult) {
// Otherwise, consume the source map (hopefully from cache), and resolve the
// original line numbers
originalLineResult = (async () => {
const sourceMapResult = JSON.parse(await readFile(mapFilePath, 'utf8'));
return _sourceMap.SourceMapConsumer.with(await sourceMapResult, undefined, source => {
return source.originalPositionFor({
column,
line
});
});
})();
}
cachedOriginalLines[lineKey] = originalLineResult;
return originalLineResult;
};
const resolveCallSiteSourceCodeLocation = async callSite => {

@@ -43,9 +71,3 @@ if (!(0, _isCallSiteSourceCodeLocationResolvable.default)(callSite)) {

if ((0, _isReadableFile.default)(maybeMapFilePath)) {
const rawSourceMap = JSON.parse(_fs.default.readFileSync(maybeMapFilePath, 'utf8'));
const consumer = await new _sourceMap.SourceMapConsumer(rawSourceMap);
const originalPosition = consumer.originalPositionFor({
column: columnNumber,
line: lineNumber
});
await consumer.destroy();
const originalPosition = await resolveOriginalPosition(maybeMapFilePath, columnNumber, lineNumber);

@@ -52,0 +74,0 @@ if (originalPosition.source) {

@@ -33,2 +33,4 @@ {

"husky": "^3.1.0",
"mock-fs": "^5.0.0",
"nodemark": "^0.3.0",
"nyc": "^14.1.1"

@@ -71,5 +73,6 @@ },

"lint": "eslint ./src ./test && flow",
"test": "NODE_ENV=test nyc ava --verbose --serial --concurrency 1"
"test": "NODE_ENV=test nyc ava --verbose --serial --concurrency 1",
"benchmark": "node performance/benchmark.js"
},
"version": "2.0.3"
"version": "2.1.0"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc