Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / lang / isError.js
1 var isObjectLike = require('../internal/isObjectLike');
2
3 /** `Object#toString` result references. */
4 var errorTag = '[object Error]';
5
6 /** Used for native method references. */
7 var objectProto = Object.prototype;
8
9 /**
10  * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
11  * of values.
12  */
13 var objToString = objectProto.toString;
14
15 /**
16  * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
17  * `SyntaxError`, `TypeError`, or `URIError` object.
18  *
19  * @static
20  * @memberOf _
21  * @category Lang
22  * @param {*} value The value to check.
23  * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
24  * @example
25  *
26  * _.isError(new Error);
27  * // => true
28  *
29  * _.isError(Error);
30  * // => false
31  */
32 function isError(value) {
33   return isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag;
34 }
35
36 module.exports = isError;