parcoursup/node_modules/loupe/lib/promise.js
lalBi94 7bc56c09b5 $
2023-03-05 13:23:23 +01:00

17 lines
541 B
JavaScript

let getPromiseValue = () => 'Promise{…}'
try {
const { getPromiseDetails, kPending, kRejected } = process.binding('util')
if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
getPromiseValue = (value, options) => {
const [state, innerValue] = getPromiseDetails(value)
if (state === kPending) {
return 'Promise{<pending>}'
}
return `Promise${state === kRejected ? '!' : ''}{${options.inspect(innerValue, options)}}`
}
}
} catch (notNode) {
/* ignore */
}
export default getPromiseValue