Comparing version
@@ -6,2 +6,9 @@ # Change Log | ||
## [v3.1.0](https://github.com/BigstickCarpet/ono/tree/v3.0.0) (2017-06-01) | ||
I removed the direct dependency on [Node's `util.format()`](https://nodejs.org/api/util.html#util_util_format_format_args), which was needlessly bloating the browser bundle. Instead, I now import [`format-util`](https://www.npmjs.com/package/format-util), which a much more [lightweight browser implementation](https://github.com/tmpfs/format-util/blob/f88c550ef10c5aaadc15a7ebab595f891bb385e1/format.js). There's no change when running in Node.js, because `format-util` simply [exports `util.format()`](https://github.com/tmpfs/format-util/blob/392628c5d45e558589f2f19ffb9d79d4b5540010/index.js#L1). | ||
[Full Changelog](https://github.com/BigstickCarpet/ono/compare/v3.0.0...v3.1.0) | ||
## [v3.0.0](https://github.com/BigstickCarpet/ono/tree/v3.0.0) (2017-06-01) | ||
@@ -8,0 +15,0 @@ |
862
dist/ono.js
/*! | ||
* Ono v3.0.0 (June 4th 2017) | ||
* Ono v3.1.0 (June 12th 2017) | ||
* | ||
@@ -12,8 +12,8 @@ * https://github.com/bigstickcarpet/ono | ||
var util = require('util'), | ||
slice = Array.prototype.slice, | ||
vendorSpecificErrorProperties = [ | ||
'name', 'message', 'description', 'number', 'fileName', 'lineNumber', 'columnNumber', | ||
'sourceURL', 'line', 'column', 'stack' | ||
]; | ||
var format = require('format-util'); | ||
var slice = Array.prototype.slice; | ||
var vendorSpecificErrorProperties = [ | ||
'name', 'message', 'description', 'number', 'fileName', 'lineNumber', 'columnNumber', | ||
'sourceURL', 'line', 'column', 'stack' | ||
]; | ||
@@ -28,3 +28,3 @@ module.exports = create(Error); | ||
module.exports.uri = create(URIError); | ||
module.exports.formatter = util.format; | ||
module.exports.formatter = format; | ||
@@ -47,13 +47,15 @@ /** | ||
var formattedMessage; | ||
var formatter = module.exports.formatter; | ||
if (typeof (err) === 'string') { | ||
formattedMessage = formatter.apply(null, arguments); | ||
if (typeof err === 'string') { | ||
formattedMessage = module.exports.formatter.apply(null, arguments); | ||
err = props = undefined; | ||
} | ||
else if (typeof (props) === 'string') { | ||
formattedMessage = formatter.apply(null, slice.call(arguments, 1)); | ||
else if (typeof props === 'string') { | ||
formattedMessage = module.exports.formatter.apply(null, slice.call(arguments, 1)); | ||
} | ||
else if (typeof message === 'string') { | ||
formattedMessage = module.exports.formatter.apply(null, slice.call(arguments, 2)); | ||
} | ||
else { | ||
formattedMessage = formatter.apply(null, slice.call(arguments, 2)); | ||
formattedMessage = ''; | ||
} | ||
@@ -115,3 +117,3 @@ | ||
function extend (target, source, omitVendorSpecificProperties) { | ||
if (source && typeof (source) === 'object') { | ||
if (source && typeof source === 'object') { | ||
var keys = Object.keys(source); | ||
@@ -313,813 +315,43 @@ for (var i = 0; i < keys.length; i++) { | ||
},{"util":5}],2:[function(require,module,exports){ | ||
// shim for using process in browser | ||
var process = module.exports = {}; | ||
// cached from whatever global is present so that test runners that stub it | ||
// don't break things. But we need to wrap it in a try catch in case it is | ||
// wrapped in strict mode code which doesn't define any globals. It's inside a | ||
// function because try/catches deoptimize in certain engines. | ||
var cachedSetTimeout; | ||
var cachedClearTimeout; | ||
function defaultSetTimout() { | ||
throw new Error('setTimeout has not been defined'); | ||
} | ||
function defaultClearTimeout () { | ||
throw new Error('clearTimeout has not been defined'); | ||
} | ||
(function () { | ||
try { | ||
if (typeof setTimeout === 'function') { | ||
cachedSetTimeout = setTimeout; | ||
} else { | ||
cachedSetTimeout = defaultSetTimout; | ||
} | ||
} catch (e) { | ||
cachedSetTimeout = defaultSetTimout; | ||
} | ||
try { | ||
if (typeof clearTimeout === 'function') { | ||
cachedClearTimeout = clearTimeout; | ||
} else { | ||
cachedClearTimeout = defaultClearTimeout; | ||
} | ||
} catch (e) { | ||
cachedClearTimeout = defaultClearTimeout; | ||
} | ||
} ()) | ||
function runTimeout(fun) { | ||
if (cachedSetTimeout === setTimeout) { | ||
//normal enviroments in sane situations | ||
return setTimeout(fun, 0); | ||
} | ||
// if setTimeout wasn't available but was latter defined | ||
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { | ||
cachedSetTimeout = setTimeout; | ||
return setTimeout(fun, 0); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedSetTimeout(fun, 0); | ||
} catch(e){ | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedSetTimeout.call(null, fun, 0); | ||
} catch(e){ | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error | ||
return cachedSetTimeout.call(this, fun, 0); | ||
} | ||
} | ||
} | ||
function runClearTimeout(marker) { | ||
if (cachedClearTimeout === clearTimeout) { | ||
//normal enviroments in sane situations | ||
return clearTimeout(marker); | ||
} | ||
// if clearTimeout wasn't available but was latter defined | ||
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { | ||
cachedClearTimeout = clearTimeout; | ||
return clearTimeout(marker); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedClearTimeout(marker); | ||
} catch (e){ | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedClearTimeout.call(null, marker); | ||
} catch (e){ | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. | ||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout | ||
return cachedClearTimeout.call(this, marker); | ||
} | ||
} | ||
} | ||
var queue = []; | ||
var draining = false; | ||
var currentQueue; | ||
var queueIndex = -1; | ||
function cleanUpNextTick() { | ||
if (!draining || !currentQueue) { | ||
return; | ||
} | ||
draining = false; | ||
if (currentQueue.length) { | ||
queue = currentQueue.concat(queue); | ||
} else { | ||
queueIndex = -1; | ||
} | ||
if (queue.length) { | ||
drainQueue(); | ||
} | ||
} | ||
function drainQueue() { | ||
if (draining) { | ||
return; | ||
} | ||
var timeout = runTimeout(cleanUpNextTick); | ||
draining = true; | ||
var len = queue.length; | ||
while(len) { | ||
currentQueue = queue; | ||
queue = []; | ||
while (++queueIndex < len) { | ||
if (currentQueue) { | ||
currentQueue[queueIndex].run(); | ||
} | ||
} | ||
queueIndex = -1; | ||
len = queue.length; | ||
} | ||
currentQueue = null; | ||
draining = false; | ||
runClearTimeout(timeout); | ||
} | ||
process.nextTick = function (fun) { | ||
var args = new Array(arguments.length - 1); | ||
if (arguments.length > 1) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
} | ||
queue.push(new Item(fun, args)); | ||
if (queue.length === 1 && !draining) { | ||
runTimeout(drainQueue); | ||
} | ||
}; | ||
// v8 likes predictible objects | ||
function Item(fun, array) { | ||
this.fun = fun; | ||
this.array = array; | ||
} | ||
Item.prototype.run = function () { | ||
this.fun.apply(null, this.array); | ||
}; | ||
process.title = 'browser'; | ||
process.browser = true; | ||
process.env = {}; | ||
process.argv = []; | ||
process.version = ''; // empty string to avoid regexp issues | ||
process.versions = {}; | ||
function noop() {} | ||
process.on = noop; | ||
process.addListener = noop; | ||
process.once = noop; | ||
process.off = noop; | ||
process.removeListener = noop; | ||
process.removeAllListeners = noop; | ||
process.emit = noop; | ||
process.prependListener = noop; | ||
process.prependOnceListener = noop; | ||
process.listeners = function (name) { return [] } | ||
process.binding = function (name) { | ||
throw new Error('process.binding is not supported'); | ||
}; | ||
process.cwd = function () { return '/' }; | ||
process.chdir = function (dir) { | ||
throw new Error('process.chdir is not supported'); | ||
}; | ||
process.umask = function() { return 0; }; | ||
},{}],3:[function(require,module,exports){ | ||
if (typeof Object.create === 'function') { | ||
// implementation from standard node.js 'util' module | ||
module.exports = function inherits(ctor, superCtor) { | ||
ctor.super_ = superCtor | ||
ctor.prototype = Object.create(superCtor.prototype, { | ||
constructor: { | ||
value: ctor, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
},{"format-util":2}],2:[function(require,module,exports){ | ||
function format(fmt) { | ||
var re = /(%?)(%([jds]))/g | ||
, args = Array.prototype.slice.call(arguments, 1); | ||
if(args.length) { | ||
fmt = fmt.replace(re, function(match, escaped, ptn, flag) { | ||
var arg = args.shift(); | ||
switch(flag) { | ||
case 's': | ||
arg = '' + arg; | ||
break; | ||
case 'd': | ||
arg = Number(arg); | ||
break; | ||
case 'j': | ||
arg = JSON.stringify(arg); | ||
break; | ||
} | ||
}); | ||
}; | ||
} else { | ||
// old school shim for old browsers | ||
module.exports = function inherits(ctor, superCtor) { | ||
ctor.super_ = superCtor | ||
var TempCtor = function () {} | ||
TempCtor.prototype = superCtor.prototype | ||
ctor.prototype = new TempCtor() | ||
ctor.prototype.constructor = ctor | ||
} | ||
} | ||
},{}],4:[function(require,module,exports){ | ||
module.exports = function isBuffer(arg) { | ||
return arg && typeof arg === 'object' | ||
&& typeof arg.copy === 'function' | ||
&& typeof arg.fill === 'function' | ||
&& typeof arg.readUInt8 === 'function'; | ||
} | ||
},{}],5:[function(require,module,exports){ | ||
(function (process,global){ | ||
// Copyright Joyent, Inc. and other Node contributors. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a | ||
// copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to permit | ||
// persons to whom the Software is furnished to do so, subject to the | ||
// following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included | ||
// in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
// USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
var formatRegExp = /%[sdj%]/g; | ||
exports.format = function(f) { | ||
if (!isString(f)) { | ||
var objects = []; | ||
for (var i = 0; i < arguments.length; i++) { | ||
objects.push(inspect(arguments[i])); | ||
} | ||
return objects.join(' '); | ||
} | ||
var i = 1; | ||
var args = arguments; | ||
var len = args.length; | ||
var str = String(f).replace(formatRegExp, function(x) { | ||
if (x === '%%') return '%'; | ||
if (i >= len) return x; | ||
switch (x) { | ||
case '%s': return String(args[i++]); | ||
case '%d': return Number(args[i++]); | ||
case '%j': | ||
try { | ||
return JSON.stringify(args[i++]); | ||
} catch (_) { | ||
return '[Circular]'; | ||
} | ||
default: | ||
return x; | ||
} | ||
}); | ||
for (var x = args[i]; i < len; x = args[++i]) { | ||
if (isNull(x) || !isObject(x)) { | ||
str += ' ' + x; | ||
} else { | ||
str += ' ' + inspect(x); | ||
} | ||
} | ||
return str; | ||
}; | ||
// Mark that a method should not be used. | ||
// Returns a modified function which warns once by default. | ||
// If --no-deprecation is set, then it is a no-op. | ||
exports.deprecate = function(fn, msg) { | ||
// Allow for deprecating things in the process of starting up. | ||
if (isUndefined(global.process)) { | ||
return function() { | ||
return exports.deprecate(fn, msg).apply(this, arguments); | ||
}; | ||
} | ||
if (process.noDeprecation === true) { | ||
return fn; | ||
} | ||
var warned = false; | ||
function deprecated() { | ||
if (!warned) { | ||
if (process.throwDeprecation) { | ||
throw new Error(msg); | ||
} else if (process.traceDeprecation) { | ||
console.trace(msg); | ||
} else { | ||
console.error(msg); | ||
if(!escaped) { | ||
return arg; | ||
} | ||
warned = true; | ||
} | ||
return fn.apply(this, arguments); | ||
args.unshift(arg); | ||
return match; | ||
}) | ||
} | ||
return deprecated; | ||
}; | ||
var debugs = {}; | ||
var debugEnviron; | ||
exports.debuglog = function(set) { | ||
if (isUndefined(debugEnviron)) | ||
debugEnviron = process.env.NODE_DEBUG || ''; | ||
set = set.toUpperCase(); | ||
if (!debugs[set]) { | ||
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { | ||
var pid = process.pid; | ||
debugs[set] = function() { | ||
var msg = exports.format.apply(exports, arguments); | ||
console.error('%s %d: %s', set, pid, msg); | ||
}; | ||
} else { | ||
debugs[set] = function() {}; | ||
} | ||
// arguments remain after formatting | ||
if(args.length) { | ||
fmt += ' ' + args.join(' '); | ||
} | ||
return debugs[set]; | ||
}; | ||
// update escaped %% values | ||
fmt = fmt.replace(/%{2,2}/g, '%'); | ||
/** | ||
* Echos the value of a value. Trys to print the value out | ||
* in the best way possible given the different types. | ||
* | ||
* @param {Object} obj The object to print out. | ||
* @param {Object} opts Optional options object that alters the output. | ||
*/ | ||
/* legacy: obj, showHidden, depth, colors*/ | ||
function inspect(obj, opts) { | ||
// default options | ||
var ctx = { | ||
seen: [], | ||
stylize: stylizeNoColor | ||
}; | ||
// legacy... | ||
if (arguments.length >= 3) ctx.depth = arguments[2]; | ||
if (arguments.length >= 4) ctx.colors = arguments[3]; | ||
if (isBoolean(opts)) { | ||
// legacy... | ||
ctx.showHidden = opts; | ||
} else if (opts) { | ||
// got an "options" object | ||
exports._extend(ctx, opts); | ||
} | ||
// set default options | ||
if (isUndefined(ctx.showHidden)) ctx.showHidden = false; | ||
if (isUndefined(ctx.depth)) ctx.depth = 2; | ||
if (isUndefined(ctx.colors)) ctx.colors = false; | ||
if (isUndefined(ctx.customInspect)) ctx.customInspect = true; | ||
if (ctx.colors) ctx.stylize = stylizeWithColor; | ||
return formatValue(ctx, obj, ctx.depth); | ||
return '' + fmt; | ||
} | ||
exports.inspect = inspect; | ||
module.exports = format; | ||
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics | ||
inspect.colors = { | ||
'bold' : [1, 22], | ||
'italic' : [3, 23], | ||
'underline' : [4, 24], | ||
'inverse' : [7, 27], | ||
'white' : [37, 39], | ||
'grey' : [90, 39], | ||
'black' : [30, 39], | ||
'blue' : [34, 39], | ||
'cyan' : [36, 39], | ||
'green' : [32, 39], | ||
'magenta' : [35, 39], | ||
'red' : [31, 39], | ||
'yellow' : [33, 39] | ||
}; | ||
// Don't use 'blue' not visible on cmd.exe | ||
inspect.styles = { | ||
'special': 'cyan', | ||
'number': 'yellow', | ||
'boolean': 'yellow', | ||
'undefined': 'grey', | ||
'null': 'bold', | ||
'string': 'green', | ||
'date': 'magenta', | ||
// "name": intentionally not styling | ||
'regexp': 'red' | ||
}; | ||
function stylizeWithColor(str, styleType) { | ||
var style = inspect.styles[styleType]; | ||
if (style) { | ||
return '\u001b[' + inspect.colors[style][0] + 'm' + str + | ||
'\u001b[' + inspect.colors[style][1] + 'm'; | ||
} else { | ||
return str; | ||
} | ||
} | ||
function stylizeNoColor(str, styleType) { | ||
return str; | ||
} | ||
function arrayToHash(array) { | ||
var hash = {}; | ||
array.forEach(function(val, idx) { | ||
hash[val] = true; | ||
}); | ||
return hash; | ||
} | ||
function formatValue(ctx, value, recurseTimes) { | ||
// Provide a hook for user-specified inspect functions. | ||
// Check that value is an object with an inspect function on it | ||
if (ctx.customInspect && | ||
value && | ||
isFunction(value.inspect) && | ||
// Filter out the util module, it's inspect function is special | ||
value.inspect !== exports.inspect && | ||
// Also filter out any prototype objects using the circular check. | ||
!(value.constructor && value.constructor.prototype === value)) { | ||
var ret = value.inspect(recurseTimes, ctx); | ||
if (!isString(ret)) { | ||
ret = formatValue(ctx, ret, recurseTimes); | ||
} | ||
return ret; | ||
} | ||
// Primitive types cannot have properties | ||
var primitive = formatPrimitive(ctx, value); | ||
if (primitive) { | ||
return primitive; | ||
} | ||
// Look up the keys of the object. | ||
var keys = Object.keys(value); | ||
var visibleKeys = arrayToHash(keys); | ||
if (ctx.showHidden) { | ||
keys = Object.getOwnPropertyNames(value); | ||
} | ||
// IE doesn't make error fields non-enumerable | ||
// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx | ||
if (isError(value) | ||
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { | ||
return formatError(value); | ||
} | ||
// Some type of object without properties can be shortcutted. | ||
if (keys.length === 0) { | ||
if (isFunction(value)) { | ||
var name = value.name ? ': ' + value.name : ''; | ||
return ctx.stylize('[Function' + name + ']', 'special'); | ||
} | ||
if (isRegExp(value)) { | ||
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); | ||
} | ||
if (isDate(value)) { | ||
return ctx.stylize(Date.prototype.toString.call(value), 'date'); | ||
} | ||
if (isError(value)) { | ||
return formatError(value); | ||
} | ||
} | ||
var base = '', array = false, braces = ['{', '}']; | ||
// Make Array say that they are Array | ||
if (isArray(value)) { | ||
array = true; | ||
braces = ['[', ']']; | ||
} | ||
// Make functions say that they are functions | ||
if (isFunction(value)) { | ||
var n = value.name ? ': ' + value.name : ''; | ||
base = ' [Function' + n + ']'; | ||
} | ||
// Make RegExps say that they are RegExps | ||
if (isRegExp(value)) { | ||
base = ' ' + RegExp.prototype.toString.call(value); | ||
} | ||
// Make dates with properties first say the date | ||
if (isDate(value)) { | ||
base = ' ' + Date.prototype.toUTCString.call(value); | ||
} | ||
// Make error with message first say the error | ||
if (isError(value)) { | ||
base = ' ' + formatError(value); | ||
} | ||
if (keys.length === 0 && (!array || value.length == 0)) { | ||
return braces[0] + base + braces[1]; | ||
} | ||
if (recurseTimes < 0) { | ||
if (isRegExp(value)) { | ||
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); | ||
} else { | ||
return ctx.stylize('[Object]', 'special'); | ||
} | ||
} | ||
ctx.seen.push(value); | ||
var output; | ||
if (array) { | ||
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); | ||
} else { | ||
output = keys.map(function(key) { | ||
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); | ||
}); | ||
} | ||
ctx.seen.pop(); | ||
return reduceToSingleString(output, base, braces); | ||
} | ||
function formatPrimitive(ctx, value) { | ||
if (isUndefined(value)) | ||
return ctx.stylize('undefined', 'undefined'); | ||
if (isString(value)) { | ||
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') | ||
.replace(/'/g, "\\'") | ||
.replace(/\\"/g, '"') + '\''; | ||
return ctx.stylize(simple, 'string'); | ||
} | ||
if (isNumber(value)) | ||
return ctx.stylize('' + value, 'number'); | ||
if (isBoolean(value)) | ||
return ctx.stylize('' + value, 'boolean'); | ||
// For some reason typeof null is "object", so special case here. | ||
if (isNull(value)) | ||
return ctx.stylize('null', 'null'); | ||
} | ||
function formatError(value) { | ||
return '[' + Error.prototype.toString.call(value) + ']'; | ||
} | ||
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { | ||
var output = []; | ||
for (var i = 0, l = value.length; i < l; ++i) { | ||
if (hasOwnProperty(value, String(i))) { | ||
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, | ||
String(i), true)); | ||
} else { | ||
output.push(''); | ||
} | ||
} | ||
keys.forEach(function(key) { | ||
if (!key.match(/^\d+$/)) { | ||
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, | ||
key, true)); | ||
} | ||
}); | ||
return output; | ||
} | ||
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { | ||
var name, str, desc; | ||
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; | ||
if (desc.get) { | ||
if (desc.set) { | ||
str = ctx.stylize('[Getter/Setter]', 'special'); | ||
} else { | ||
str = ctx.stylize('[Getter]', 'special'); | ||
} | ||
} else { | ||
if (desc.set) { | ||
str = ctx.stylize('[Setter]', 'special'); | ||
} | ||
} | ||
if (!hasOwnProperty(visibleKeys, key)) { | ||
name = '[' + key + ']'; | ||
} | ||
if (!str) { | ||
if (ctx.seen.indexOf(desc.value) < 0) { | ||
if (isNull(recurseTimes)) { | ||
str = formatValue(ctx, desc.value, null); | ||
} else { | ||
str = formatValue(ctx, desc.value, recurseTimes - 1); | ||
} | ||
if (str.indexOf('\n') > -1) { | ||
if (array) { | ||
str = str.split('\n').map(function(line) { | ||
return ' ' + line; | ||
}).join('\n').substr(2); | ||
} else { | ||
str = '\n' + str.split('\n').map(function(line) { | ||
return ' ' + line; | ||
}).join('\n'); | ||
} | ||
} | ||
} else { | ||
str = ctx.stylize('[Circular]', 'special'); | ||
} | ||
} | ||
if (isUndefined(name)) { | ||
if (array && key.match(/^\d+$/)) { | ||
return str; | ||
} | ||
name = JSON.stringify('' + key); | ||
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { | ||
name = name.substr(1, name.length - 2); | ||
name = ctx.stylize(name, 'name'); | ||
} else { | ||
name = name.replace(/'/g, "\\'") | ||
.replace(/\\"/g, '"') | ||
.replace(/(^"|"$)/g, "'"); | ||
name = ctx.stylize(name, 'string'); | ||
} | ||
} | ||
return name + ': ' + str; | ||
} | ||
function reduceToSingleString(output, base, braces) { | ||
var numLinesEst = 0; | ||
var length = output.reduce(function(prev, cur) { | ||
numLinesEst++; | ||
if (cur.indexOf('\n') >= 0) numLinesEst++; | ||
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; | ||
}, 0); | ||
if (length > 60) { | ||
return braces[0] + | ||
(base === '' ? '' : base + '\n ') + | ||
' ' + | ||
output.join(',\n ') + | ||
' ' + | ||
braces[1]; | ||
} | ||
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; | ||
} | ||
// NOTE: These type checking functions intentionally don't use `instanceof` | ||
// because it is fragile and can be easily faked with `Object.create()`. | ||
function isArray(ar) { | ||
return Array.isArray(ar); | ||
} | ||
exports.isArray = isArray; | ||
function isBoolean(arg) { | ||
return typeof arg === 'boolean'; | ||
} | ||
exports.isBoolean = isBoolean; | ||
function isNull(arg) { | ||
return arg === null; | ||
} | ||
exports.isNull = isNull; | ||
function isNullOrUndefined(arg) { | ||
return arg == null; | ||
} | ||
exports.isNullOrUndefined = isNullOrUndefined; | ||
function isNumber(arg) { | ||
return typeof arg === 'number'; | ||
} | ||
exports.isNumber = isNumber; | ||
function isString(arg) { | ||
return typeof arg === 'string'; | ||
} | ||
exports.isString = isString; | ||
function isSymbol(arg) { | ||
return typeof arg === 'symbol'; | ||
} | ||
exports.isSymbol = isSymbol; | ||
function isUndefined(arg) { | ||
return arg === void 0; | ||
} | ||
exports.isUndefined = isUndefined; | ||
function isRegExp(re) { | ||
return isObject(re) && objectToString(re) === '[object RegExp]'; | ||
} | ||
exports.isRegExp = isRegExp; | ||
function isObject(arg) { | ||
return typeof arg === 'object' && arg !== null; | ||
} | ||
exports.isObject = isObject; | ||
function isDate(d) { | ||
return isObject(d) && objectToString(d) === '[object Date]'; | ||
} | ||
exports.isDate = isDate; | ||
function isError(e) { | ||
return isObject(e) && | ||
(objectToString(e) === '[object Error]' || e instanceof Error); | ||
} | ||
exports.isError = isError; | ||
function isFunction(arg) { | ||
return typeof arg === 'function'; | ||
} | ||
exports.isFunction = isFunction; | ||
function isPrimitive(arg) { | ||
return arg === null || | ||
typeof arg === 'boolean' || | ||
typeof arg === 'number' || | ||
typeof arg === 'string' || | ||
typeof arg === 'symbol' || // ES6 symbol | ||
typeof arg === 'undefined'; | ||
} | ||
exports.isPrimitive = isPrimitive; | ||
exports.isBuffer = require('./support/isBuffer'); | ||
function objectToString(o) { | ||
return Object.prototype.toString.call(o); | ||
} | ||
function pad(n) { | ||
return n < 10 ? '0' + n.toString(10) : n.toString(10); | ||
} | ||
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', | ||
'Oct', 'Nov', 'Dec']; | ||
// 26 Feb 16:19:34 | ||
function timestamp() { | ||
var d = new Date(); | ||
var time = [pad(d.getHours()), | ||
pad(d.getMinutes()), | ||
pad(d.getSeconds())].join(':'); | ||
return [d.getDate(), months[d.getMonth()], time].join(' '); | ||
} | ||
// log is just a thin wrapper to console.log that prepends a timestamp | ||
exports.log = function() { | ||
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); | ||
}; | ||
/** | ||
* Inherit the prototype methods from one constructor into another. | ||
* | ||
* The Function.prototype.inherits from lang.js rewritten as a standalone | ||
* function (not on Function.prototype). NOTE: If this file is to be loaded | ||
* during bootstrapping this function needs to be rewritten using some native | ||
* functions as prototype setup using normal JavaScript does not work as | ||
* expected during bootstrapping (see mirror.js in r114903). | ||
* | ||
* @param {function} ctor Constructor function which needs to inherit the | ||
* prototype. | ||
* @param {function} superCtor Constructor function to inherit prototype from. | ||
*/ | ||
exports.inherits = require('inherits'); | ||
exports._extend = function(origin, add) { | ||
// Don't do anything if add isn't an object | ||
if (!add || !isObject(add)) return origin; | ||
var keys = Object.keys(add); | ||
var i = keys.length; | ||
while (i--) { | ||
origin[keys[i]] = add[keys[i]]; | ||
} | ||
return origin; | ||
}; | ||
function hasOwnProperty(obj, prop) { | ||
return Object.prototype.hasOwnProperty.call(obj, prop); | ||
} | ||
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"./support/isBuffer":4,"_process":2,"inherits":3}]},{},[1])(1) | ||
},{}]},{},[1])(1) | ||
}); | ||
//# sourceMappingURL=ono.js.map |
/*! | ||
* Ono v3.0.0 (June 4th 2017) | ||
* Ono v3.1.0 (June 12th 2017) | ||
* | ||
@@ -9,3 +9,3 @@ * https://github.com/bigstickcarpet/ono | ||
*/ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ono=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";function create(e){return function(r,t,n,o){var c,a=module.exports.formatter;"string"==typeof r?(c=a.apply(null,arguments),r=t=void 0):c="string"==typeof t?a.apply(null,slice.call(arguments,1)):a.apply(null,slice.call(arguments,2)),r instanceof Error||(t=r,r=void 0),r&&(c+=(c?" \n":"")+r.message);var i=new e(c);return extendError(i,r),extendToJSON(i),extend(i,t),i}}function extendError(e,r){extendStack(e,r),extend(e,r,!0)}function extendToJSON(e){e.toJSON=errorToJSON,e.inspect=errorToString}function extend(e,r,t){if(r&&"object"==typeof r)for(var n=Object.keys(r),o=0;o<n.length;o++){var c=n[o];if(!(t&&vendorSpecificErrorProperties.indexOf(c)>=0))try{e[c]=r[c]}catch(e){}}}function errorToJSON(){var e={},r=Object.keys(this);r=r.concat(vendorSpecificErrorProperties);for(var t=0;t<r.length;t++){var n=r[t],o=this[n],c=typeof o;"undefined"!==c&&"function"!==c&&(e[n]=o)}return e}function errorToString(){return JSON.stringify(this,null,2).replace(/\\n/g,"\n")}function extendStack(e,r){hasLazyStack(e)?r?lazyJoinStacks(e,r):lazyPopStack(e):e.stack=r?joinStacks(e.stack,r.stack):popStack(e.stack)}function joinStacks(e,r){return e=popStack(e),e&&r?e+"\n\n"+r:e||r}function popStack(e){if(e){var r=e.split("\n");if(r.length<2)return e;for(var t=0;t<r.length;t++){if(r[t].indexOf("onoFactory")>=0)return r.splice(t,1),r.join("\n")}return e}}function hasLazyStack(e){if(!supportsLazyStack)return!1;var r=Object.getOwnPropertyDescriptor(e,"stack");return!!r&&"function"==typeof r.get}function lazyJoinStacks(e,r){var t=Object.getOwnPropertyDescriptor(e,"stack");Object.defineProperty(e,"stack",{get:function(){return joinStacks(t.get.apply(e),r.stack)},enumerable:!1,configurable:!0})}function lazyPopStack(e){var r=Object.getOwnPropertyDescriptor(e,"stack");Object.defineProperty(e,"stack",{get:function(){return popStack(r.get.apply(e))},enumerable:!1,configurable:!0})}var util=require("util"),slice=Array.prototype.slice,vendorSpecificErrorProperties=["name","message","description","number","fileName","lineNumber","columnNumber","sourceURL","line","column","stack"];module.exports=create(Error),module.exports.error=create(Error),module.exports.eval=create(EvalError),module.exports.range=create(RangeError),module.exports.reference=create(ReferenceError),module.exports.syntax=create(SyntaxError),module.exports.type=create(TypeError),module.exports.uri=create(URIError),module.exports.formatter=util.format;var supportsLazyStack=function(){return!(!Object.getOwnPropertyDescriptor||!Object.defineProperty||"undefined"!=typeof navigator&&/Android/.test(navigator.userAgent))}()},{util:5}],2:[function(require,module,exports){function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch(t){try{return cachedSetTimeout.call(null,e,0)}catch(t){return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch(t){try{return cachedClearTimeout.call(null,e)}catch(t){return cachedClearTimeout.call(this,e)}}}function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(e)}}function Item(e,t){this.fun=e,this.array=t}function noop(){}var process=module.exports={},cachedSetTimeout,cachedClearTimeout;!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var queue=[],draining=!1,currentQueue,queueIndex=-1;process.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];queue.push(new Item(e,t)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(e){return[]},process.binding=function(e){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(e){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}},{}],3:[function(require,module,exports){"function"==typeof Object.create?module.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(t,e){t.super_=e;var o=function(){};o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t}},{}],4:[function(require,module,exports){module.exports=function(o){return o&&"object"==typeof o&&"function"==typeof o.copy&&"function"==typeof o.fill&&"function"==typeof o.readUInt8}},{}],5:[function(require,module,exports){(function(process,global){function inspect(e,r){var t={seen:[],stylize:stylizeNoColor};return arguments.length>=3&&(t.depth=arguments[2]),arguments.length>=4&&(t.colors=arguments[3]),isBoolean(r)?t.showHidden=r:r&&exports._extend(t,r),isUndefined(t.showHidden)&&(t.showHidden=!1),isUndefined(t.depth)&&(t.depth=2),isUndefined(t.colors)&&(t.colors=!1),isUndefined(t.customInspect)&&(t.customInspect=!0),t.colors&&(t.stylize=stylizeWithColor),formatValue(t,e,t.depth)}function stylizeWithColor(e,r){var t=inspect.styles[r];return t?"["+inspect.colors[t][0]+"m"+e+"["+inspect.colors[t][1]+"m":e}function stylizeNoColor(e,r){return e}function arrayToHash(e){var r={};return e.forEach(function(e,t){r[e]=!0}),r}function formatValue(e,r,t){if(e.customInspect&&r&&isFunction(r.inspect)&&r.inspect!==exports.inspect&&(!r.constructor||r.constructor.prototype!==r)){var n=r.inspect(t,e);return isString(n)||(n=formatValue(e,n,t)),n}var i=formatPrimitive(e,r);if(i)return i;var o=Object.keys(r),s=arrayToHash(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(r)),isError(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return formatError(r);if(0===o.length){if(isFunction(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(isRegExp(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(isDate(r))return e.stylize(Date.prototype.toString.call(r),"date");if(isError(r))return formatError(r)}var c="",a=!1,l=["{","}"];if(isArray(r)&&(a=!0,l=["[","]"]),isFunction(r)){c=" [Function"+(r.name?": "+r.name:"")+"]"}if(isRegExp(r)&&(c=" "+RegExp.prototype.toString.call(r)),isDate(r)&&(c=" "+Date.prototype.toUTCString.call(r)),isError(r)&&(c=" "+formatError(r)),0===o.length&&(!a||0==r.length))return l[0]+c+l[1];if(t<0)return isRegExp(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special");e.seen.push(r);var p;return p=a?formatArray(e,r,t,s,o):o.map(function(n){return formatProperty(e,r,t,s,n,a)}),e.seen.pop(),reduceToSingleString(p,c,l)}function formatPrimitive(e,r){if(isUndefined(r))return e.stylize("undefined","undefined");if(isString(r)){var t="'"+JSON.stringify(r).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(t,"string")}return isNumber(r)?e.stylize(""+r,"number"):isBoolean(r)?e.stylize(""+r,"boolean"):isNull(r)?e.stylize("null","null"):void 0}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,r,t,n,i){for(var o=[],s=0,u=r.length;s<u;++s)hasOwnProperty(r,String(s))?o.push(formatProperty(e,r,t,n,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(formatProperty(e,r,t,n,i,!0))}),o}function formatProperty(e,r,t,n,i,o){var s,u,c;if(c=Object.getOwnPropertyDescriptor(r,i)||{value:r[i]},c.get?u=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(u=e.stylize("[Setter]","special")),hasOwnProperty(n,i)||(s="["+i+"]"),u||(e.seen.indexOf(c.value)<0?(u=isNull(t)?formatValue(e,c.value,null):formatValue(e,c.value,t-1),u.indexOf("\n")>-1&&(u=o?u.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+u.split("\n").map(function(e){return" "+e}).join("\n"))):u=e.stylize("[Circular]","special")),isUndefined(s)){if(o&&i.match(/^\d+$/))return u;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+u}function reduceToSingleString(e,r,t){var n=0;return e.reduce(function(e,r){return n++,r.indexOf("\n")>=0&&n++,e+r.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?t[0]+(""===r?"":r+"\n ")+" "+e.join(",\n ")+" "+t[1]:t[0]+r+" "+e.join(", ")+" "+t[1]}function isArray(e){return Array.isArray(e)}function isBoolean(e){return"boolean"==typeof e}function isNull(e){return null===e}function isNullOrUndefined(e){return null==e}function isNumber(e){return"number"==typeof e}function isString(e){return"string"==typeof e}function isSymbol(e){return"symbol"==typeof e}function isUndefined(e){return void 0===e}function isRegExp(e){return isObject(e)&&"[object RegExp]"===objectToString(e)}function isObject(e){return"object"==typeof e&&null!==e}function isDate(e){return isObject(e)&&"[object Date]"===objectToString(e)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(e){return"function"==typeof e}function isPrimitive(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function objectToString(e){return Object.prototype.toString.call(e)}function pad(e){return e<10?"0"+e.toString(10):e.toString(10)}function timestamp(){var e=new Date,r=[pad(e.getHours()),pad(e.getMinutes()),pad(e.getSeconds())].join(":");return[e.getDate(),months[e.getMonth()],r].join(" ")}function hasOwnProperty(e,r){return Object.prototype.hasOwnProperty.call(e,r)}var formatRegExp=/%[sdj%]/g;exports.format=function(e){if(!isString(e)){for(var r=[],t=0;t<arguments.length;t++)r.push(inspect(arguments[t]));return r.join(" ")}for(var t=1,n=arguments,i=n.length,o=String(e).replace(formatRegExp,function(e){if("%%"===e)return"%";if(t>=i)return e;switch(e){case"%s":return String(n[t++]);case"%d":return Number(n[t++]);case"%j":try{return JSON.stringify(n[t++])}catch(e){return"[Circular]"}default:return e}}),s=n[t];t<i;s=n[++t])isNull(s)||!isObject(s)?o+=" "+s:o+=" "+inspect(s);return o},exports.deprecate=function(e,r){function t(){if(!n){if(process.throwDeprecation)throw new Error(r);process.traceDeprecation?console.trace(r):console.error(r),n=!0}return e.apply(this,arguments)}if(isUndefined(global.process))return function(){return exports.deprecate(e,r).apply(this,arguments)};if(!0===process.noDeprecation)return e;var n=!1;return t};var debugs={},debugEnviron;exports.debuglog=function(e){if(isUndefined(debugEnviron)&&(debugEnviron=process.env.NODE_DEBUG||""),e=e.toUpperCase(),!debugs[e])if(new RegExp("\\b"+e+"\\b","i").test(debugEnviron)){var r=process.pid;debugs[e]=function(){var t=exports.format.apply(exports,arguments);console.error("%s %d: %s",e,r,t)}}else debugs[e]=function(){};return debugs[e]},exports.inspect=inspect,inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=require("./support/isBuffer");var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))},exports.inherits=require("inherits"),exports._extend=function(e,r){if(!r||!isObject(r))return e;for(var t=Object.keys(r),n=t.length;n--;)e[t[n]]=r[t[n]];return e}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":4,_process:2,inherits:3}]},{},[1])(1)}); | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ono=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";function create(e){return function(r,t,o,n){var a;"string"==typeof r?(a=module.exports.formatter.apply(null,arguments),r=t=void 0):a="string"==typeof t?module.exports.formatter.apply(null,slice.call(arguments,1)):"string"==typeof o?module.exports.formatter.apply(null,slice.call(arguments,2)):"",r instanceof Error||(t=r,r=void 0),r&&(a+=(a?" \n":"")+r.message);var c=new e(a);return extendError(c,r),extendToJSON(c),extend(c,t),c}}function extendError(e,r){extendStack(e,r),extend(e,r,!0)}function extendToJSON(e){e.toJSON=errorToJSON,e.inspect=errorToString}function extend(e,r,t){if(r&&"object"==typeof r)for(var o=Object.keys(r),n=0;n<o.length;n++){var a=o[n];if(!(t&&vendorSpecificErrorProperties.indexOf(a)>=0))try{e[a]=r[a]}catch(e){}}}function errorToJSON(){var e={},r=Object.keys(this);r=r.concat(vendorSpecificErrorProperties);for(var t=0;t<r.length;t++){var o=r[t],n=this[o],a=typeof n;"undefined"!==a&&"function"!==a&&(e[o]=n)}return e}function errorToString(){return JSON.stringify(this,null,2).replace(/\\n/g,"\n")}function extendStack(e,r){hasLazyStack(e)?r?lazyJoinStacks(e,r):lazyPopStack(e):e.stack=r?joinStacks(e.stack,r.stack):popStack(e.stack)}function joinStacks(e,r){return e=popStack(e),e&&r?e+"\n\n"+r:e||r}function popStack(e){if(e){var r=e.split("\n");if(r.length<2)return e;for(var t=0;t<r.length;t++){if(r[t].indexOf("onoFactory")>=0)return r.splice(t,1),r.join("\n")}return e}}function hasLazyStack(e){if(!supportsLazyStack)return!1;var r=Object.getOwnPropertyDescriptor(e,"stack");return!!r&&"function"==typeof r.get}function lazyJoinStacks(e,r){var t=Object.getOwnPropertyDescriptor(e,"stack");Object.defineProperty(e,"stack",{get:function(){return joinStacks(t.get.apply(e),r.stack)},enumerable:!1,configurable:!0})}function lazyPopStack(e){var r=Object.getOwnPropertyDescriptor(e,"stack");Object.defineProperty(e,"stack",{get:function(){return popStack(r.get.apply(e))},enumerable:!1,configurable:!0})}var format=require("format-util"),slice=Array.prototype.slice,vendorSpecificErrorProperties=["name","message","description","number","fileName","lineNumber","columnNumber","sourceURL","line","column","stack"];module.exports=create(Error),module.exports.error=create(Error),module.exports.eval=create(EvalError),module.exports.range=create(RangeError),module.exports.reference=create(ReferenceError),module.exports.syntax=create(SyntaxError),module.exports.type=create(TypeError),module.exports.uri=create(URIError),module.exports.formatter=format;var supportsLazyStack=function(){return!(!Object.getOwnPropertyDescriptor||!Object.defineProperty||"undefined"!=typeof navigator&&/Android/.test(navigator.userAgent))}()},{"format-util":2}],2:[function(require,module,exports){function format(e){var r=/(%?)(%([jds]))/g,t=Array.prototype.slice.call(arguments,1);return t.length&&(e=e.replace(r,function(e,r,a,n){var s=t.shift();switch(n){case"s":s=""+s;break;case"d":s=Number(s);break;case"j":s=JSON.stringify(s)}return r?(t.unshift(s),e):s})),t.length&&(e+=" "+t.join(" ")),""+(e=e.replace(/%{2,2}/g,"%"))}module.exports=format},{}]},{},[1])(1)}); | ||
//# sourceMappingURL=ono.min.js.map |
{ | ||
"name": "ono", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Throw better errors.", | ||
@@ -25,3 +25,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"main": "lib/index.js", | ||
"main": "lib/ono.js", | ||
"files": [ | ||
@@ -32,7 +32,7 @@ "dist/ono.js", | ||
"dist/ono.min.js.map", | ||
"lib/index.js" | ||
"lib" | ||
], | ||
"scripts": { | ||
"lint": "eslint lib test/fixtures test/specs --fix", | ||
"build": "simplifyify lib/index.js --outfile dist/ono.js --standalone ono --bundle --debug --minify", | ||
"build": "simplifyify lib/ono.js --outfile dist/ono.js --standalone ono --bundle --debug --minify", | ||
"test": "mocha && npm run karma && npm run lint", | ||
@@ -47,7 +47,7 @@ "mocha": "mocha", | ||
"devDependencies": { | ||
"chai": "^4.0.0", | ||
"chai": "^4.0.2", | ||
"codacy-coverage": "^2.0.2", | ||
"coveralls": "^2.13.1", | ||
"eslint": "^3.19.0", | ||
"eslint-config-modular": "^4.0.0", | ||
"eslint": "^4.0.0", | ||
"eslint-config-modular": "^4.1.0", | ||
"istanbul": "^0.4.2", | ||
@@ -71,3 +71,5 @@ "karma": "^1.7.0", | ||
}, | ||
"dependencies": {} | ||
"dependencies": { | ||
"format-util": "^1.0.3" | ||
} | ||
} |
@@ -5,4 +5,4 @@ ono (Oh No!) | ||
[](https://travis-ci.org/BigstickCarpet/ono) | ||
[](https://ci.appveyor.com/project/BigstickCarpet/ono) | ||
[](https://travis-ci.org/BigstickCarpet/ono) | ||
[](https://ci.appveyor.com/project/BigstickCarpet/ono) | ||
@@ -22,3 +22,3 @@ [](https://coveralls.io/r/BigstickCarpet/ono) | ||
-------------------------- | ||
* Formatted error messages, using Node's [`util.format()`](https://nodejs.org/api/util.html#util_util_format_format) or your own custom formatter | ||
* Formatted error messages, using Node's [`util.format()`](https://nodejs.org/api/util.html#util_util_format_format_args) or your own custom formatter | ||
* Wrap and re-throw an error _without_ losing the original error's message, stack trace, and properties | ||
@@ -25,0 +25,0 @@ * Add custom properties to your errors — great for error codes, support numbers, help URLs, etc. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
4
-50%61747
-59.53%1
Infinity%601
-53.95%1
Infinity%+ Added
+ Added