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

Function onwriteError

browser.js:25291–25313  ·  view source on GitHub ↗
(stream, state, sync, er, cb)

Source from the content-addressed store, hash-verified

25289}
25290
25291function onwriteError(stream, state, sync, er, cb) {
25292 --state.pendingcb;
25293
25294 if (sync) {
25295 // defer the callback if we are being called synchronously
25296 // to avoid piling up things on the stack
25297 pna.nextTick(cb, er);
25298 // this can emit finish, and it will always happen
25299 // after error
25300 pna.nextTick(finishMaybe, stream, state);
25301 stream._writableState.errorEmitted = true;
25302 stream.emit('error', er);
25303 } else {
25304 // the caller expect this to happen before if
25305 // it is async
25306 cb(er);
25307 stream._writableState.errorEmitted = true;
25308 stream.emit('error', er);
25309 // this can emit finish, but finish must
25310 // always follow error
25311 finishMaybe(stream, state);
25312 }
25313}
25314
25315function onwriteStateUpdate(state) {
25316 state.writing = false;

Callers 1

onwriteFunction · 0.70

Calls 2

cbFunction · 0.85
finishMaybeFunction · 0.70

Tested by

no test coverage detected