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

stackman

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stackman - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

err1.js

33

index.js

@@ -22,2 +22,3 @@ 'use strict';

callback({
// culprit:
properties: getProperties(err),

@@ -34,2 +35,3 @@ frames: stack

callsite.getRelativeFileName = getRelativeFileName.bind(callsite);
callsite.getTypeNameSafely = getTypeNameSafely.bind(callsite);
callsite.getFunctionNameSanitized = getFunctionNameSanitized.bind(callsite);

@@ -88,6 +90,5 @@ callsite.getModuleName = getModuleName.bind(callsite);

var getFunctionNameSanitized = function () {
var getTypeNameSafely = function () {
try {
return this.getFunctionName() ||
this.getTypeName() + '.' + (this.getMethodName() || '<anonymous>');
return this.getTypeName();
} catch (e) {

@@ -97,6 +98,30 @@ // This seems to happen sometimes when using 'use strict',

// [TypeError: Cannot read property 'constructor' of undefined]
return '<anonymous>';
return null;
}
};
var getFunctionNameSanitized = function () {
var fnName = this.getFunctionName();
if (fnName) return fnName;
var typeName = this.getTypeNameSafely();
if (typeName) return typeName + '.' + (this.getMethodName() || '<anonymous>');
return '<anonymous>';
};
var getCulprit = function () {
// module
// file
// function/object/method
//
// ModuleName: file.function
// ModuleName: Type.method
var filename;
if (this.isNode()) {
filename = this.getFileName();
} else {
}
var module = this.getModuleName();
};
var getModuleName = function () {

@@ -103,0 +128,0 @@ var filename = this.getFileName() || '';

2

package.json
{
"name": "stackman",
"version": "0.2.1",
"version": "0.2.2",
"description": "Enhance an error stacktrace with code excerpts and other goodies",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -77,2 +77,3 @@ # Stackman

- `callsite.getTypeNameSafely()` - A safer version of `callsite.getTypeName()` as this safely handles an exception that sometimes is thrown when using `"use strict"`. Otherwise it returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property
- `callsite.getRelativeFileName()` - Returns a filename realtive to `process.cwd()`

@@ -79,0 +80,0 @@ - `callsite.getFunctionNameSanitized()` - Guaranteed to always return the most meaningful function name. If none can be determined, the string `<anonymous>` will be returned

@@ -8,2 +8,14 @@ 'use strict';

test('should override getTypeName() and safely catch exception', function (t) {
process.nextTick(function () {
var err = new Error('foo');
stackman()(err, function (stack) {
var frame =stack.frames[0];
var name = frame.getFunctionNameSanitized();
t.equal(name, '<anonymous>', 'should safely catch exception');
t.end();
});
});
});
test('should call the callback with a stack object', function (t) {

@@ -10,0 +22,0 @@ var err = new Error();

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