UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

20 lines (19 loc) 475 B
//#region src/predicate/isError.ts /** * Checks if `value` is an Error object. * * @param value The value to check. * @returns 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 value instanceof Error; } //#endregion export { isError };