mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
inspector: refactor inspector/promises
to be more robust
Limit the effect of users mutating `node:util`, `node:inspector`, or `Array.prototype`. PR-URL: https://github.com/nodejs/node/pull/45041 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
f2aac0b36b
commit
9926b89a99
@ -1,20 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const inspector = require('inspector');
|
const inspector = require('inspector');
|
||||||
const { promisify } = require('util');
|
const { promisify } = require('internal/util');
|
||||||
const { FunctionPrototypeBind } = primordials;
|
|
||||||
class Session extends inspector.Session {
|
class Session extends inspector.Session {
|
||||||
#post = promisify(FunctionPrototypeBind(super.post, this));
|
constructor() { super(); } // eslint-disable-line no-useless-constructor
|
||||||
/**
|
|
||||||
* Posts a message to the inspector back-end.
|
|
||||||
* @param {string} method
|
|
||||||
* @param {Record<unknown, unknown>} [params]
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
|
||||||
async post(method, params) {
|
|
||||||
return this.#post(method, params);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Session.prototype.post = promisify(inspector.Session.prototype.post);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...inspector,
|
...inspector,
|
||||||
|
Loading…
Reference in New Issue
Block a user