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

Function handleWriteReq

lib/internal/stream_base_commons.js:46–79  ·  view source on GitHub ↗
(req, data, encoding)

Source from the content-addressed store, hash-verified

44const kBufferCb = Symbol('kBufferCb');
45
46function handleWriteReq(req, data, encoding) {
47 const { handle } = req;
48
49 switch (encoding) {
50 case 'buffer':
51 {
52 const ret = handle.writeBuffer(req, data);
53 if (streamBaseState[kLastWriteWasAsync])
54 req.buffer = data;
55 return ret;
56 }
57 case 'latin1':
58 case 'binary':
59 return handle.writeLatin1String(req, data);
60 case 'utf8':
61 case 'utf-8':
62 return handle.writeUtf8String(req, data);
63 case 'ascii':
64 return handle.writeAsciiString(req, data);
65 case 'ucs2':
66 case 'ucs-2':
67 case 'utf16le':
68 case 'utf-16le':
69 return handle.writeUcs2String(req, data);
70 default:
71 {
72 const buffer = Buffer.from(data, encoding);
73 const ret = handle.writeBuffer(req, buffer);
74 if (streamBaseState[kLastWriteWasAsync])
75 req.buffer = buffer;
76 return ret;
77 }
78 }
79}
80
81function onWriteComplete(status) {
82 debug('onWriteComplete', status, this.error);

Callers 1

writeGenericFunction · 0.85

Calls 1

fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…