Files
emaui/node_modules/es-toolkit/dist/compat/predicate/isError.mjs
2026-05-29 15:23:46 +03:00

21 lines
567 B
JavaScript

import { getTag } from "../_internal/getTag.mjs";
//#region src/compat/predicate/isError.ts
/**
* Checks if `value` is an Error object.
*
* @param {any} value The value to check.
* @returns {value is Error} Returns `true` if `value` is an Error object, `false` otherwise.
*
* @example
* ```typescript
* console.log(isError(new Error())); // true
* console.log(isError('Error')); // false
* console.log(isError({ name: 'Error', message: '' })); // false
* ```
*/
function isError(value) {
return getTag(value) === "[object Error]";
}
//#endregion
export { isError };