Package Exports
- @silen/is-promise
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@silen/is-promise) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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