Skip to content

Commit

Permalink
stream: fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
rluvaton committed Aug 10, 2023
1 parent 804399a commit 9cfa60d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
17 changes: 9 additions & 8 deletions lib/internal/webstreams/readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ class ReadableStreamDefaultController {
[kType] = 'ReadableStreamDefaultController';

constructor(skipThrowSymbol) {
if (new.target === ReadableStreamDefaultController || skipThrowSymbol !== kSkipThrow) {
if (skipThrowSymbol !== kSkipThrow) {
throw new ERR_ILLEGAL_CONSTRUCTOR();
}
}
Expand Down Expand Up @@ -1079,12 +1079,13 @@ ObjectDefineProperties(ReadableStreamDefaultController.prototype, {
[SymbolToStringTag]: getNonWritablePropertyDescriptor(ReadableStreamDefaultController.name),
});

class ReadableStreamDefaultControllerClazz extends ReadableStreamDefaultController {
constructor(skipThrowSymbol) {
super(skipThrowSymbol);
this[kType] = 'ReadableStreamDefaultController';
this[kState] = {};
}
function createReadableStreamDefaultController() {
const controller = new ReadableStreamDefaultController(kSkipThrow);

controller[kType] = 'ReadableStreamDefaultController';
controller[kState] = {};

return controller;
}

class ReadableByteStreamController {
Expand Down Expand Up @@ -2415,7 +2416,7 @@ function setupReadableStreamDefaultControllerFromSource(
source,
highWaterMark,
sizeAlgorithm) {
const controller = new ReadableStreamDefaultControllerClazz(kSkipThrow);
const controller = createReadableStreamDefaultController();
const start = source?.start;
const pull = source?.pull;
const cancel = source?.cancel;
Expand Down
12 changes: 6 additions & 6 deletions lib/internal/webstreams/transformstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
PromiseResolve,
ReflectConstruct,
SymbolToStringTag,
Symbol,
} = primordials;

const {
Expand Down Expand Up @@ -334,11 +335,10 @@ ObjectDefineProperties(TransformStreamDefaultController.prototype, {
[SymbolToStringTag]: getNonWritablePropertyDescriptor(TransformStreamDefaultController.name),
});

class TransformStreamDefaultControllerClazz extends TransformStreamDefaultController {
constructor(skipThrowSymbol) {
super(skipThrowSymbol);
this[kType] = 'TransformStreamDefaultController';
}
function createTransformStreamDefaultController() {
const controller = new TransformStreamDefaultController(kSkipThrow);
controller[kType] = 'TransformStreamDefaultController';
return controller;
}

const isTransformStream =
Expand Down Expand Up @@ -455,7 +455,7 @@ function setupTransformStreamDefaultController(
function setupTransformStreamDefaultControllerFromTransformer(
stream,
transformer) {
const controller = new TransformStreamDefaultControllerClazz(kSkipThrow);
const controller = createTransformStreamDefaultController();
const transform = transformer?.transform || defaultTransformAlgorithm;
const flush = transformer?.flush || nonOpFlush;
const transformAlgorithm =
Expand Down
13 changes: 6 additions & 7 deletions lib/internal/webstreams/writablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ class WritableStreamDefaultController {
[kType] = 'WritableStreamDefaultController';

constructor(skipThrowSymbol) {
if (new.target === WritableStreamDefaultController || skipThrowSymbol !== kSkipThrow) {
if (skipThrowSymbol !== kSkipThrow) {
throw new ERR_ILLEGAL_CONSTRUCTOR();
}
}
Expand Down Expand Up @@ -572,11 +572,10 @@ ObjectDefineProperties(WritableStreamDefaultController.prototype, {
[SymbolToStringTag]: getNonWritablePropertyDescriptor(WritableStreamDefaultController.name),
});

class WritableStreamDefaultControllerClazz extends WritableStreamDefaultController {
constructor(skipThrowSymbol) {
super(skipThrowSymbol);
this[kType] = 'WritableStreamDefaultController';
}
function createWritableStreamDefaultController() {
const controller = new WritableStreamDefaultController(kSkipThrow);
controller[kType] = 'WritableStreamDefaultController';
return controller;
}

const isWritableStream =
Expand Down Expand Up @@ -1235,7 +1234,7 @@ function setupWritableStreamDefaultControllerFromSink(
sink,
highWaterMark,
sizeAlgorithm) {
const controller = new WritableStreamDefaultControllerClazz(kSkipThrow);
const controller = createWritableStreamDefaultController();
const start = sink?.start;
const write = sink?.write;
const close = sink?.close;
Expand Down

0 comments on commit 9cfa60d

Please sign in to comment.