mirror of
https://github.com/soconnor0919/beenpad.git
synced 2026-02-05 00:06:40 -05:00
first commit
This commit is contained in:
1
node_modules/stackback/.npmignore
generated
vendored
Normal file
1
node_modules/stackback/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
4
node_modules/stackback/.travis.yml
generated
vendored
Normal file
4
node_modules/stackback/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
- 0.8
|
||||
41
node_modules/stackback/README.md
generated
vendored
Normal file
41
node_modules/stackback/README.md
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# stackback
|
||||
|
||||
Returns an array of CallSite objects for a captured stacktrace. Useful if you want to access the frame for an error object.
|
||||
|
||||
## use
|
||||
|
||||
```javascript
|
||||
var stackback = require('stackback');
|
||||
|
||||
// error generated from somewhere
|
||||
var err = new Error('some sample error');
|
||||
|
||||
// stack is an array of CallSite objects
|
||||
var stack = stackback(err);
|
||||
```
|
||||
|
||||
## CallSite object
|
||||
|
||||
From the [V8 StackTrace API](https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi)
|
||||
|
||||
The structured stack trace is an Array of CallSite objects, each of which represents a stack frame. A CallSite object defines the following methods
|
||||
|
||||
getThis: returns the value of this
|
||||
getTypeName: 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.
|
||||
getFunction: returns the current function
|
||||
getFunctionName: returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context.
|
||||
getMethodName: returns the name of the property of this or one of its prototypes that holds the current function
|
||||
getFileName: if this function was defined in a script returns the name of the script
|
||||
getLineNumber: if this function was defined in a script returns the current line number
|
||||
getColumnNumber: if this function was defined in a script returns the current column number
|
||||
getEvalOrigin: if this function was created using a call to eval returns a CallSite object representing the location where eval was called
|
||||
isToplevel: is this a toplevel invocation, that is, is this the global object?
|
||||
isEval: does this call take place in code defined by a call to eval?
|
||||
isNative: is this call in native V8 code?
|
||||
isConstructor: is this a constructor call?
|
||||
|
||||
## install
|
||||
|
||||
```shell
|
||||
npm install stackback
|
||||
```
|
||||
57
node_modules/stackback/formatstack.js
generated
vendored
Normal file
57
node_modules/stackback/formatstack.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright 2012 the V8 project authors. All rights reserved.
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
function FormatStackTrace(error, frames) {
|
||||
var lines = [];
|
||||
try {
|
||||
lines.push(error.toString());
|
||||
} catch (e) {
|
||||
try {
|
||||
lines.push("<error: " + e + ">");
|
||||
} catch (ee) {
|
||||
lines.push("<error>");
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < frames.length; i++) {
|
||||
var frame = frames[i];
|
||||
var line;
|
||||
try {
|
||||
line = frame.toString();
|
||||
} catch (e) {
|
||||
try {
|
||||
line = "<error: " + e + ">";
|
||||
} catch (ee) {
|
||||
// Any code that reaches this point is seriously nasty!
|
||||
line = "<error>";
|
||||
}
|
||||
}
|
||||
lines.push(" at " + line);
|
||||
}
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
module.exports = FormatStackTrace;
|
||||
46
node_modules/stackback/index.js
generated
vendored
Normal file
46
node_modules/stackback/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
// v8 builtin format stack trace
|
||||
// for when there was no previous prepareStackTrace function to call
|
||||
var FormatStackTrace = require('./formatstack');
|
||||
|
||||
// some notes on the behavior below:
|
||||
// because the 'stack' member is a one shot access variable (the raw stack is
|
||||
// formatted on accessing it)
|
||||
// we try to avoid modifying what the user would have wanted
|
||||
// thus we use the previous value for prepareStackTrace
|
||||
//
|
||||
// The reason we store the callsite variable is because prepareStackTrace
|
||||
// will not be called again once it has been called for a given error object
|
||||
// but we want to support getting the stack out of the error multiple times (cause why not)
|
||||
module.exports = function(err) {
|
||||
|
||||
// save original stacktrace
|
||||
var save = Error.prepareStackTrace;
|
||||
|
||||
// replace capture with our function
|
||||
Error.prepareStackTrace = function(err, trace) {
|
||||
|
||||
// cache stack frames so we don't have to get them again
|
||||
// use a non-enumerable property
|
||||
Object.defineProperty(err, '_sb_callsites', {
|
||||
value: trace
|
||||
});
|
||||
|
||||
return (save || FormatStackTrace)(err, trace);
|
||||
};
|
||||
|
||||
// force capture of the stack frames
|
||||
err.stack;
|
||||
|
||||
// someone already asked for the stack so we can't do this trick
|
||||
// TODO fallback to string parsing?
|
||||
if (!err._sb_callsites) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// return original capture function
|
||||
Error.prepareStackTrace = save;
|
||||
|
||||
return err._sb_callsites;
|
||||
};
|
||||
|
||||
23
node_modules/stackback/package.json
generated
vendored
Normal file
23
node_modules/stackback/package.json
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "stackback",
|
||||
"version": "0.0.2",
|
||||
"description": "return list of CallSite objects from a captured stacktrace",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "mocha --ui qunit"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/shtylman/node-stackback.git"
|
||||
},
|
||||
"keywords": [
|
||||
"stacktrace",
|
||||
"trace",
|
||||
"stack"
|
||||
],
|
||||
"devDependencies": {
|
||||
"mocha": "~1.6.0"
|
||||
},
|
||||
"author": "Roman Shtylman <shtylman@gmail.com>",
|
||||
"license": "MIT"
|
||||
}
|
||||
24
node_modules/stackback/test.js
generated
vendored
Normal file
24
node_modules/stackback/test.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
var assert = require('assert');
|
||||
var stackback = require('./');
|
||||
|
||||
test('capture', function() {
|
||||
var err = new Error();
|
||||
var stack = stackback(err);
|
||||
assert.equal(stack[0].getFileName(), __filename);
|
||||
});
|
||||
|
||||
// calling stackback on the same error twice should work
|
||||
test('multiple calls', function() {
|
||||
var err = new Error();
|
||||
var stack1 = stackback(err);
|
||||
var stack2 = stackback(err);
|
||||
assert.equal(stack1[0].getFileName(), __filename);
|
||||
assert.deepEqual(stack1, stack2);
|
||||
});
|
||||
|
||||
test('string', function() {
|
||||
var err = new Error();
|
||||
stackback(err);
|
||||
assert.equal(typeof err.stack, 'string');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user