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

Function readFileAfterClose

lib/internal/fs/read/context.js:71–97  ·  view source on GitHub ↗
(err)

Source from the content-addressed store, hash-verified

69}
70
71function readFileAfterClose(err) {
72 const context = this.context;
73 const callback = context.callback;
74 let buffer = null;
75
76 if (context.err || err)
77 return callback(aggregateTwoErrors(err, context.err));
78
79 try {
80 if (context.userBuffer) {
81 buffer = context.buffer.subarray(0, context.pos);
82 } else if (context.size === 0) {
83 buffer = Buffer.concat(context.buffers, context.pos);
84 } else if (context.pos < context.size) {
85 buffer = context.buffer.slice(0, context.pos);
86 } else {
87 buffer = context.buffer;
88 }
89
90 if (context.encoding)
91 buffer = buffer.toString(context.encoding);
92 } catch (err) {
93 return callback(err);
94 }
95
96 callback(null, buffer);
97}
98
99class ReadFileContext {
100 constructor(callback, options) {

Callers

nothing calls this directly

Calls 5

aggregateTwoErrorsFunction · 0.85
concatMethod · 0.80
sliceMethod · 0.65
callbackFunction · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…