buddhism/uni.promisify.adaptor.js

17 lines
349 B
JavaScript
Raw Permalink Normal View History

2023-11-27 09:57:03 +08:00
uni.addInterceptor({
2025-08-14 11:22:53 +08:00
returnValue(res) {
if (
!(
!!res &&
(typeof res === 'object' || typeof res === 'function') &&
typeof res.then === 'function'
)
) {
return res
2023-11-27 09:57:03 +08:00
}
return new Promise((resolve, reject) => {
2025-08-14 11:22:53 +08:00
res.then(res => (res[0] ? reject(res[0]) : resolve(res[1])))
})
2023-11-27 09:57:03 +08:00
},
2025-08-14 11:22:53 +08:00
})