callsite-record
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -251,5 +251,14 @@ var fs = require('fs'); | ||
CallsiteRecord.fromError = function (error) { | ||
CallsiteRecord.fromError = function (error, isCallsiteFrame) { | ||
var stackFrames = stackParser.parse(error); | ||
if (typeof isCallsiteFrame === 'function') { | ||
while (stackFrames.length) { | ||
if (!isCallsiteFrame(stackFrames[0])) | ||
stackFrames.shift(); | ||
else | ||
break; | ||
} | ||
} | ||
if (stackFrames.length) { | ||
@@ -266,5 +275,5 @@ var filename = stackFrames[0].getFileName(); | ||
// API | ||
module.exports = function createCallsiteRecord (/* err || fnName, typeName */) { | ||
module.exports = function createCallsiteRecord (/* err, isCallsiteFrame || fnName, typeName */) { | ||
if (arguments[0] instanceof Error) | ||
return CallsiteRecord.fromError(arguments[0]); | ||
return CallsiteRecord.fromError(arguments[0], arguments[1]); | ||
@@ -271,0 +280,0 @@ else if (typeof arguments[0] === 'string') { |
{ | ||
"name": "callsite-record", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Create fancy log entries for errors and function call sites.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -61,5 +61,7 @@ # callsite-record | ||
## API | ||
### createCallsiteRecord(error) → CallsiteRecord | ||
### createCallsiteRecord(error, [isCallsiteFrame]) → CallsiteRecord | ||
Creates `CallsiteRecord` for `error`. | ||
You can generate a callsite for any stack frame, not only the topmost one. Use the `isCallsiteFrame` function to select | ||
a frame. This function is called for each frame starting from the top. Return `true` for the desired frame to generate | ||
the callsite. | ||
@@ -66,0 +68,0 @@ *Example:* |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19448
302
190