Skip to content

Commit

Permalink
Merge pull request #3 from Asana/sean-expose-get-promise-details
Browse files Browse the repository at this point in the history
expose process.binding('util').getPromiseDetails
  • Loading branch information
seanwentzel authored Jan 8, 2024
2 parents afe9b08 + e2961a4 commit bc56465
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/internal/bootstrap/realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,15 @@ const experimentalModuleList = new SafeSet();
'DEP0111');
}
if (legacyWrapperList.has(module)) {
return requireBuiltin('internal/legacy/processbinding')[module]();
const legacy = requireBuiltin('internal/legacy/processbinding')[module]();
if (module === 'util') {
// We need getPromiseDetails and constants.kFulfilled from `internalBinding('util')`
return {
...legacy,
...internalBinding('util'),
};
}
return legacy;
}
return internalBinding(module);
}
Expand Down
20 changes: 19 additions & 1 deletion test/parallel/test-process-binding-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@ const utilBinding = process.binding('util');
assert.deepStrictEqual(
Object.keys(utilBinding).sort(),
[
'WeakReference',
'arrayBufferViewHasBuffer',
'constants',
'getCallerLocation',
'getConstructorName',
'getExternalValue',
'getOwnNonIndexProperties',
'getPromiseDetails',
'getProxyDetails',
'guessHandleType',
'isAnyArrayBuffer',
'isArrayBuffer',
'isArrayBufferDetached',
'isArrayBufferView',
'isAsyncFunction',
'isDataView',
Expand All @@ -23,8 +34,15 @@ assert.deepStrictEqual(
'isSetIterator',
'isTypedArray',
'isUint8Array',
'previewEntries',
'privateSymbols',
'shouldAbortOnUncaughtToggle',
'sleep',
'toUSVString',
]);

for (const k of Object.keys(utilBinding)) {
assert.strictEqual(utilBinding[k], util.types[k]);
if (k in util.types) {
assert.strictEqual(utilBinding[k], util.types[k]);
}
}

0 comments on commit bc56465

Please sign in to comment.