aboutsummaryrefslogtreecommitdiff
path: root/node_modules/when/monitor/error.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/when/monitor/error.js')
-rw-r--r--node_modules/when/monitor/error.js86
1 files changed, 0 insertions, 86 deletions
diff --git a/node_modules/when/monitor/error.js b/node_modules/when/monitor/error.js
deleted file mode 100644
index 63825e2c..00000000
--- a/node_modules/when/monitor/error.js
+++ /dev/null
@@ -1,86 +0,0 @@
-/** @license MIT License (c) copyright 2010-2014 original author or authors */
-/** @author Brian Cavalier */
-/** @author John Hann */
-
-(function(define) { 'use strict';
-define(function() {
-
- var parse, captureStack, format;
-
- if(Error.captureStackTrace) {
- // Use Error.captureStackTrace if available
- parse = function(e) {
- return e && e.stack && e.stack.split('\n');
- };
-
- format = formatAsString;
- captureStack = Error.captureStackTrace;
-
- } else {
- // Otherwise, do minimal feature detection to determine
- // how to capture and format reasonable stacks.
- parse = function(e) {
- var stack = e && e.stack && e.stack.split('\n');
- if(stack && e.message) {
- stack.unshift(e.message);
- }
- return stack;
- };
-
- (function() {
- var e = new Error();
- if(typeof e.stack !== 'string') {
- format = formatAsString;
- captureStack = captureSpiderMonkeyStack;
- } else {
- format = formatAsErrorWithStack;
- captureStack = useStackDirectly;
- }
- }());
- }
-
- function captureSpiderMonkeyStack(host) {
- try {
- throw new Error();
- } catch(err) {
- host.stack = err.stack;
- }
- }
-
- function useStackDirectly(host) {
- host.stack = new Error().stack;
- }
-
- function formatAsString(longTrace) {
- return join(longTrace);
- }
-
- function formatAsErrorWithStack(longTrace) {
- var e = new Error();
- e.stack = formatAsString(longTrace);
- return e;
- }
-
- // About 5-10x faster than String.prototype.join o_O
- function join(a) {
- var sep = false;
- var s = '';
- for(var i=0; i< a.length; ++i) {
- if(sep) {
- s += '\n' + a[i];
- } else {
- s+= a[i];
- sep = true;
- }
- }
- return s;
- }
-
- return {
- parse: parse,
- format: format,
- captureStack: captureStack
- };
-
-});
-}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));