@silen/is-promise
v1.0.3
Published
Check if the parameter is promise
Downloads
7
Maintainers
Readme
is-promise
Determine if a value is Promise
install
npm i @silen/is-promise
api
declare function isPromise(val: any): boolean;
usage
const { isPromise } = require('@silen/is-promise');
// or
import { isPromise } from '@silen/is-promise';
console.log(isPromise(new Buffer(4)));
console.log(isPromise(Buffer.alloc(4)));
console.log(isPromise(undefined));
console.log(isPromise(null));
console.log(isPromise(''));
console.log(isPromise(true));
console.log(isPromise(0));
console.log(isPromise(1));
console.log(isPromise(1.0));
console.log(isPromise('string'));
console.log(isPromise({}));
console.log(isPromise(function foo() {}));
console.log(isPromise(Symbol()));
console.log(isPromise(new Set));
console.log(isPromise(new Map));
console.log(isPromise(new WeakMap));
console.log(isPromise(new WeakSet));
// or
console.log(window.Type.isPromise(new WeakSet));
This is a demo for testing the usage of isPromise
from @silen/is-promise
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
- isError
- isSet
- isWeakSet
- isMap
- isWeakMap
- isStream
- isURLSearchParams