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

Function shutdownWithAction

examples/io/streams/modules/streams.js:930–949  ·  view source on GitHub ↗
(action, originalIsError, originalError)

Source from the content-addressed store, hash-verified

928 }
929
930 function shutdownWithAction(action, originalIsError, originalError) {
931 if (shuttingDown === true) {
932 return;
933 }
934 shuttingDown = true;
935
936 if (dest.state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
937 waitForWritesToFinish().then(doTheRest).catch(ignoreReason);
938 }
939 else {
940 doTheRest();
941 }
942
943 function doTheRest() {
944 action().then(
945 () => finalize(originalIsError, originalError),
946 newError => finalize(true, newError)
947 );
948 }
949 }
950
951 function shutdown(isError, error) {
952 if (shuttingDown === true) {

Callers 1

ReadableStreamPipeToFunction · 0.85

Calls 3

waitForWritesToFinishFunction · 0.85
doTheRestFunction · 0.85

Tested by

no test coverage detected