MCPcopy
hub / github.com/BrainJS/brain.js / onwrite

Function onwrite

browser.js:25322–25345  ·  view source on GitHub ↗
(stream, er)

Source from the content-addressed store, hash-verified

25320}
25321
25322function onwrite(stream, er) {
25323 var state = stream._writableState;
25324 var sync = state.sync;
25325 var cb = state.writecb;
25326
25327 onwriteStateUpdate(state);
25328
25329 if (er) onwriteError(stream, state, sync, er, cb);else {
25330 // Check if we're actually ready to finish, but don't emit yet
25331 var finished = needFinish(state);
25332
25333 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
25334 clearBuffer(stream, state);
25335 }
25336
25337 if (sync) {
25338 /*<replacement>*/
25339 asyncWrite(afterWrite, stream, state, finished, cb);
25340 /*</replacement>*/
25341 } else {
25342 afterWrite(stream, state, finished, cb);
25343 }
25344 }
25345}
25346
25347function afterWrite(stream, state, finished, cb) {
25348 if (!finished) onwriteDrain(stream, state);

Callers 1

WritableStateFunction · 0.70

Calls 5

onwriteStateUpdateFunction · 0.70
onwriteErrorFunction · 0.70
needFinishFunction · 0.70
clearBufferFunction · 0.70
afterWriteFunction · 0.70

Tested by

no test coverage detected