MCPcopy Index your code
hub / github.com/nodejs/node / finish

Function finish

lib/internal/streams/writable.js:949–971  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

947}
948
949function finish(stream, state) {
950 state.pendingcb--;
951 state[kState] |= kFinished;
952
953 callFinishedCallbacks(state, null);
954
955 stream.emit('finish');
956
957 if ((state[kState] & kAutoDestroy) !== 0) {
958 // In case of duplex streams we need a way to detect
959 // if the readable side is ready for autoDestroy as well.
960 const rState = stream._readableState;
961 const autoDestroy = !rState || (
962 rState.autoDestroy &&
963 // We don't expect the readable to ever 'end'
964 // if readable is explicitly set to false.
965 (rState.endEmitted || rState.readable === false)
966 );
967 if (autoDestroy) {
968 stream.destroy();
969 }
970 }
971}
972
973function callFinishedCallbacks(state, err) {
974 if ((state[kState] & kOnFinished) === 0) {

Callers 1

finishMaybeFunction · 0.70

Calls 3

callFinishedCallbacksFunction · 0.85
emitMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…