File size: 541 Bytes
369fac9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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