aboutsummaryrefslogtreecommitdiffstats
path: root/vanilla/node_modules/stackback
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-13 21:34:48 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-13 21:34:48 -0800
commit76cb9c2a39d477a64824a985ade40507e3bbade1 (patch)
tree41e997aa9c6f538d3a136af61dae9424db2005a9 /vanilla/node_modules/stackback
parent819a39a21ac992b1393244a4c283bbb125208c69 (diff)
downloadneko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.gz
neko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.bz2
neko-76cb9c2a39d477a64824a985ade40507e3bbade1.zip
feat(vanilla): add testing infrastructure and tests (NK-wjnczv)
Diffstat (limited to 'vanilla/node_modules/stackback')
-rw-r--r--vanilla/node_modules/stackback/.npmignore1
-rw-r--r--vanilla/node_modules/stackback/.travis.yml4
-rw-r--r--vanilla/node_modules/stackback/README.md41
-rw-r--r--vanilla/node_modules/stackback/formatstack.js57
-rw-r--r--vanilla/node_modules/stackback/index.js46
-rw-r--r--vanilla/node_modules/stackback/package.json23
-rw-r--r--vanilla/node_modules/stackback/test.js24
7 files changed, 196 insertions, 0 deletions
diff --git a/vanilla/node_modules/stackback/.npmignore b/vanilla/node_modules/stackback/.npmignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/vanilla/node_modules/stackback/.npmignore
@@ -0,0 +1 @@
+node_modules
diff --git a/vanilla/node_modules/stackback/.travis.yml b/vanilla/node_modules/stackback/.travis.yml
new file mode 100644
index 0000000..320698a
--- /dev/null
+++ b/vanilla/node_modules/stackback/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
diff --git a/vanilla/node_modules/stackback/README.md b/vanilla/node_modules/stackback/README.md
new file mode 100644
index 0000000..fb6bde7
--- /dev/null
+++ b/vanilla/node_modules/stackback/README.md
@@ -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
+```
diff --git a/vanilla/node_modules/stackback/formatstack.js b/vanilla/node_modules/stackback/formatstack.js
new file mode 100644
index 0000000..d64307d
--- /dev/null
+++ b/vanilla/node_modules/stackback/formatstack.js
@@ -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;
diff --git a/vanilla/node_modules/stackback/index.js b/vanilla/node_modules/stackback/index.js
new file mode 100644
index 0000000..8b87042
--- /dev/null
+++ b/vanilla/node_modules/stackback/index.js
@@ -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;
+};
+
diff --git a/vanilla/node_modules/stackback/package.json b/vanilla/node_modules/stackback/package.json
new file mode 100644
index 0000000..3e8b7b2
--- /dev/null
+++ b/vanilla/node_modules/stackback/package.json
@@ -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"
+}
diff --git a/vanilla/node_modules/stackback/test.js b/vanilla/node_modules/stackback/test.js
new file mode 100644
index 0000000..212b414
--- /dev/null
+++ b/vanilla/node_modules/stackback/test.js
@@ -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');
+});
+