GitHub 6248★

Check if an object is a Promise

JavaScript version

const isPromise = (obj) => !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';

TypeScript version

const isPromise = (obj: any): boolean => !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
Follow me on and to get more useful contents.