diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:43:05 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 22:18:30 +0800 |
| commit | 89e95b3f143682ed9a006991bacf45c9dcba4818 (patch) | |
| tree | 4f44cf41b828577d583890bdd5a1c31e8491a6ba /node_modules/when/monitor/error.js | |
| parent | aa7f0199255277949790b41c56e8ec97dd4f0da4 (diff) | |
| download | xmake-docs-vuepress.tar.gz xmake-docs-vuepress.zip | |
remove node_modulesvuepress
Diffstat (limited to 'node_modules/when/monitor/error.js')
| -rw-r--r-- | node_modules/when/monitor/error.js | 86 |
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(); })); |
