1// Promise is a special type of object that helps you work with asynchronous operations.
2// Many functions will return a promise to you in situations where the value cannot be retrieved immediately.
3
4const userCount = getUserCount();
5console.log(userCount); // Promise {<pending>}
6
7// In this case, getUserCount is the function that returns a Promise. If we try to immediately display the value of the userCount variable, we get something like Promise {<pending>}.
8// This will happen because there is no data yet and we need to wait for it.
1import isPromise from 'is-promise';
2
3isPromise(Promise.resolve());//=>true
4isPromise({then:function () {...}});//=>true
5isPromise(null);//=>false
6isPromise({});//=>false
7isPromise({then: true})//=>false