dotfiles/.vscode/extensions/vscodevim.vim-0.2.0/node_modules/lodash/isError.js

43 lines
1 KiB
JavaScript
Raw Normal View History

2016-09-11 09:29:13 +01:00
var isObjectLike = require('./isObjectLike');
/** `Object#toString` result references. */
var errorTag = '[object Error]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
* `SyntaxError`, `TypeError`, or `URIError` object.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an error object, else `false`.
* @example
*
* _.isError(new Error);
* // => true
*
* _.isError(Error);
* // => false
*/
function isError(value) {
if (!isObjectLike(value)) {
return false;
}
return (objectToString.call(value) == errorTag) ||
(typeof value.message == 'string' && typeof value.name == 'string');
}
module.exports = isError;