🎨 Support non-native promises
This commit is contained in:
parent
4cd0de0e87
commit
32073fa079
5 changed files with 24 additions and 4 deletions
|
@ -43,6 +43,11 @@ exports.defineProperties = function (exports) {
|
|||
get: function () {
|
||||
return require('../deprecations')
|
||||
}
|
||||
},
|
||||
isPromise: {
|
||||
get: function () {
|
||||
return require('../is-promise')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
14
lib/common/api/is-promise.js
Normal file
14
lib/common/api/is-promise.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = function isPromise (val) {
|
||||
return (
|
||||
val &&
|
||||
val.then &&
|
||||
val.then instanceof Function &&
|
||||
val.constructor &&
|
||||
val.constructor.reject &&
|
||||
val.constructor.reject instanceof Function &&
|
||||
val.constructor.resolve &&
|
||||
val.constructor.resolve instanceof Function
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue