You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
614 B
19 lines
614 B
1 month ago
|
let getPromiseValue = () => 'Promise{…}';
|
||
|
try {
|
||
|
// @ts-ignore
|
||
|
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;
|