@e22m4u/js-repository
Version:
Реализация репозитория для работы с базами данных в Node.js
14 lines (13 loc) • 334 B
JavaScript
/**
* Check whether a value is a Promise-like
* instance. Recognizes both native promises
* and third-party promise libraries.
*
* @param {*} value
* @returns {boolean}
*/
export function isPromise(value) {
if (!value) return false;
if (typeof value !== 'object') return false;
return typeof value.then === 'function';
}