mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Implement _.isError
This commit is contained in:
committed by
John-David Dalton
parent
976e81be43
commit
b018ada5c8
23
lodash.js
23
lodash.js
@@ -6531,6 +6531,28 @@
|
||||
return typeof value == 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is an instance of a native `Error` class.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an instance of a native `Error`, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isError(new Error);
|
||||
* // => true
|
||||
*
|
||||
* _.isError('string');
|
||||
* // => false
|
||||
*/
|
||||
function isError(value) {
|
||||
var type = typeof value;
|
||||
return value && type == 'object' && toString.call(value) == errorClass ||
|
||||
false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of the own enumerable property names of `object`.
|
||||
*
|
||||
@@ -8376,6 +8398,7 @@
|
||||
lodash.isRegExp = isRegExp;
|
||||
lodash.isString = isString;
|
||||
lodash.isUndefined = isUndefined;
|
||||
lodash.isError = isError;
|
||||
lodash.kebabCase = kebabCase;
|
||||
lodash.lastIndexOf = lastIndexOf;
|
||||
lodash.mixin = mixin;
|
||||
|
||||
Reference in New Issue
Block a user