mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
lib: revert to using default derived class constructors
PR-URL: https://github.com/nodejs/node/pull/59650 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
parent
67cb0adbc2
commit
196f5466af
|
|
@ -3,9 +3,7 @@
|
|||
const inspector = require('inspector');
|
||||
const { promisify } = require('internal/util');
|
||||
|
||||
class Session extends inspector.Session {
|
||||
constructor() { super(); } // eslint-disable-line no-useless-constructor
|
||||
}
|
||||
class Session extends inspector.Session {}
|
||||
Session.prototype.post = promisify(inspector.Session.prototype.post);
|
||||
|
||||
module.exports = {
|
||||
|
|
|
|||
|
|
@ -960,14 +960,7 @@ function writeFloatBackwards(val, offset = 0) {
|
|||
return offset;
|
||||
}
|
||||
|
||||
class FastBuffer extends Uint8Array {
|
||||
// Using an explicit constructor here is necessary to avoid relying on
|
||||
// `Array.prototype[Symbol.iterator]`, which can be mutated by users.
|
||||
// eslint-disable-next-line no-useless-constructor
|
||||
constructor(bufferOrLength, byteOffset, length) {
|
||||
super(bufferOrLength, byteOffset, length);
|
||||
}
|
||||
}
|
||||
class FastBuffer extends Uint8Array {}
|
||||
|
||||
function addBufferPrototypeMethods(proto) {
|
||||
proto.readBigUInt64LE = readBigUInt64LE;
|
||||
|
|
|
|||
|
|
@ -253,11 +253,6 @@ const {
|
|||
}
|
||||
|
||||
class AsymmetricKeyObject extends KeyObject {
|
||||
// eslint-disable-next-line no-useless-constructor
|
||||
constructor(type, handle) {
|
||||
super(type, handle);
|
||||
}
|
||||
|
||||
get asymmetricKeyType() {
|
||||
return this[kAsymmetricKeyType] ||= this[kHandle].getAsymmetricKeyType();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,7 +240,6 @@ class Pattern {
|
|||
class ResultSet extends SafeSet {
|
||||
#root = '.';
|
||||
#isExcluded = () => false;
|
||||
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||
|
||||
setup(root, isExcludedFn) {
|
||||
this.#root = root;
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ const { validateString } = require('internal/validators');
|
|||
* This cache is *not* used when custom loaders are registered.
|
||||
*/
|
||||
class ResolveCache extends SafeMap {
|
||||
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||
|
||||
/**
|
||||
* Generates the internal serialized cache key and returns it along the actual cache object.
|
||||
*
|
||||
|
|
@ -93,7 +91,6 @@ class ResolveCache extends SafeMap {
|
|||
* Cache the results of the `load` step of the module resolution and loading process.
|
||||
*/
|
||||
class LoadCache extends SafeMap {
|
||||
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||
get(url, type = kImplicitTypeAttribute) {
|
||||
validateString(url, 'url');
|
||||
validateString(type, 'type');
|
||||
|
|
|
|||
|
|
@ -401,55 +401,36 @@ primordials.makeSafe = makeSafe;
|
|||
|
||||
// Subclass the constructors because we need to use their prototype
|
||||
// methods later.
|
||||
// Defining the `constructor` is necessary here to avoid the default
|
||||
// constructor which uses the user-mutable `%ArrayIteratorPrototype%.next`.
|
||||
primordials.SafeMap = makeSafe(
|
||||
Map,
|
||||
class SafeMap extends Map {
|
||||
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||
},
|
||||
class SafeMap extends Map {},
|
||||
);
|
||||
primordials.SafeWeakMap = makeSafe(
|
||||
WeakMap,
|
||||
class SafeWeakMap extends WeakMap {
|
||||
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||
},
|
||||
class SafeWeakMap extends WeakMap {},
|
||||
);
|
||||
|
||||
primordials.SafeSet = makeSafe(
|
||||
Set,
|
||||
class SafeSet extends Set {
|
||||
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||
},
|
||||
class SafeSet extends Set {},
|
||||
);
|
||||
primordials.SafeWeakSet = makeSafe(
|
||||
WeakSet,
|
||||
class SafeWeakSet extends WeakSet {
|
||||
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||
},
|
||||
class SafeWeakSet extends WeakSet {},
|
||||
);
|
||||
|
||||
primordials.SafeFinalizationRegistry = makeSafe(
|
||||
FinalizationRegistry,
|
||||
class SafeFinalizationRegistry extends FinalizationRegistry {
|
||||
// eslint-disable-next-line no-useless-constructor
|
||||
constructor(cleanupCallback) { super(cleanupCallback); }
|
||||
},
|
||||
class SafeFinalizationRegistry extends FinalizationRegistry {},
|
||||
);
|
||||
primordials.SafeWeakRef = makeSafe(
|
||||
WeakRef,
|
||||
class SafeWeakRef extends WeakRef {
|
||||
// eslint-disable-next-line no-useless-constructor
|
||||
constructor(target) { super(target); }
|
||||
},
|
||||
class SafeWeakRef extends WeakRef {},
|
||||
);
|
||||
|
||||
const SafePromise = makeSafe(
|
||||
Promise,
|
||||
class SafePromise extends Promise {
|
||||
// eslint-disable-next-line no-useless-constructor
|
||||
constructor(executor) { super(executor); }
|
||||
},
|
||||
class SafePromise extends Promise {},
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -359,10 +359,6 @@ ObjectSetPrototypeOf(InterfaceConstructor.prototype, EventEmitter.prototype);
|
|||
ObjectSetPrototypeOf(InterfaceConstructor, EventEmitter);
|
||||
|
||||
class Interface extends InterfaceConstructor {
|
||||
// eslint-disable-next-line no-useless-constructor
|
||||
constructor(input, output, completer, terminal) {
|
||||
super(input, output, completer, terminal);
|
||||
}
|
||||
get columns() {
|
||||
if (this.output?.columns) return this.output.columns;
|
||||
return Infinity;
|
||||
|
|
|
|||
|
|
@ -97,10 +97,6 @@ function isRecoverableError(e, code) {
|
|||
.extend(
|
||||
(Parser) => {
|
||||
return class extends Parser {
|
||||
// eslint-disable-next-line no-useless-constructor
|
||||
constructor(options, input, startPos) {
|
||||
super(options, input, startPos);
|
||||
}
|
||||
nextToken() {
|
||||
super.nextToken();
|
||||
if (this.type === tt.eof)
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@ const {
|
|||
let addAbortListener;
|
||||
|
||||
class Interface extends _Interface {
|
||||
// eslint-disable-next-line no-useless-constructor
|
||||
constructor(input, output, completer, terminal) {
|
||||
super(input, output, completer, terminal);
|
||||
}
|
||||
question(query, options = kEmptyObject) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let cb = resolve;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user