@silen/is-error
v1.0.3
Published
Check if the parameter is error
Downloads
19
Maintainers
Readme
is-error
Determine if a value is Error
install
npm i @silen/is-error
api
declare function isError(val: any): boolean;
usage
const { isError } = require('@silen/is-error');
// or
import { isError } from '@silen/is-error';
console.log(isError(new Buffer(4)));
console.log(isError(Buffer.alloc(4)));
console.log(isError(undefined));
console.log(isError(null));
console.log(isError(''));
console.log(isError(true));
console.log(isError(0));
console.log(isError(1));
console.log(isError(1.0));
console.log(isError('string'));
console.log(isError({}));
console.log(isError(function foo() {}));
console.log(isError(Symbol()));
console.log(isError(new Set));
console.log(isError(new Map));
console.log(isError(new WeakMap));
console.log(isError(new WeakSet));
// or
console.log(window.Type.isError(new WeakSet));
This is a demo for testing the usage of isError
from @silen/is-error
module. You can try the others and do likewise.
others
- type
- isArray
- isUndefined
- isNull
- isBoolean
- isBuffer
- isArrayBuffer
- isFormData
- isArrayBufferView
- isString
- isNumber
- isObject
- isPlainObject
- isDate
- isArguments
- isFile
- isBlob
- isFunction
- isSymbol
- isRegExp
- isInt8Array
- isUint8Array
- isUint8ClampedArray
- isInt16Array
- isUint16Array
- isInt32Array
- isUint32Array
- isFloat32Array
- isFloat64Array
- isPromise
- isSet
- isWeakSet
- isMap
- isWeakMap
- isStream
- isURLSearchParams