MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / ReadableStreamCancel

Function ReadableStreamCancel

examples/io/streams/modules/streams.js:1326–1347  ·  view source on GitHub ↗
(stream, reason)

Source from the content-addressed store, hash-verified

1324 reader.readRequests.push(readRequest);
1325}
1326function ReadableStreamCancel(stream, reason) {
1327 stream.disturbed = true;
1328 const state = stream.state;
1329 if (state == "closed")
1330 return Promise.resolve(undefined);
1331 if (state == "errored")
1332 return Promise.reject(stream.storedError);
1333 ReadableStreamClose(stream);
1334 const reader = stream.reader;
1335 if (reader && ReadableStreamBYOBReaderBrand.has(reader.self)) {
1336 let readIntoRequests = reader.readIntoRequests;
1337 reader.readIntoRequests = [];
1338 readIntoRequests.forEach(readIntoRequest => {
1339 readIntoRequest.closeSteps(undefined);
1340 });
1341 }
1342 let promise = stream.controller.cancelSteps(reason);
1343 let then = promise.then(value => {
1344 return undefined;
1345 });
1346 return then;
1347}
1348function ReadableStreamClose(stream) {
1349 const state = stream.state;
1350 assert(state == "readable");

Callers 7

cancelMethod · 0.85
ReadableStreamPipeToFunction · 0.85
cancel1AlgorithmFunction · 0.85
cancel2AlgorithmFunction · 0.85
pullWithDefaultReaderFunction · 0.85
pullWithBYOBReaderFunction · 0.85

Calls 3

ReadableStreamCloseFunction · 0.85
resolveMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected