mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 03:34:26 +03:00
ea01c77121
* feat: add isError to predicate Co-authored-by: leeminhee119 <mhl98@dgu.ac.kr> * test: isError Co-authored-by: leeminhee119 <mhl98@dgu.ac.kr> * docs: isError Co-authored-by: leeminhee119 <mhl98@dgu.ac.kr> * feat: isError at compat Co-authored-by: leeminhee119 <mhl98@dgu.ac.kr> * feat: export to compat * fix: format Co-authored-by: leeminhee119 <mhl98@dgu.ac.kr> --------- Co-authored-by: leeminhee119 <mhl98@dgu.ac.kr>
560 B
560 B
isError
Check if the given value is an Error object.
This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to Error.
Signature
function isError(value: unknown): value is Error;
Parameters
value
(unknown
): The value to test if it is an Error object.
Returns
(value is Error
): True if the value is an Error object, otherwise false.
Examples
isError(new Error()); // true
isError('error'); // false
isError({ name: 'Error', message: '' }); // false