MCPcopy Index your code
hub / github.com/foliojs/pdfkit / readFileSync

Method readFileSync

lib/virtual-fs.js:6–23  ·  view source on GitHub ↗
(fileName, options = {})

Source from the content-addressed store, hash-verified

4 }
5
6 readFileSync(fileName, options = {}) {
7 const encoding = typeof options === 'string' ? options : options.encoding;
8 const virtualFileName = normalizeFilename(fileName);
9
10 const data = this.fileData[virtualFileName];
11 if (data == null) {
12 throw new Error(
13 `File '${virtualFileName}' not found in virtual file system`,
14 );
15 }
16
17 if (encoding) {
18 // return a string
19 return typeof data === 'string' ? data : data.toString(encoding);
20 }
21
22 return Buffer.from(data, typeof data === 'string' ? 'base64' : undefined);
23 }
24
25 writeFileSync(fileName, content) {
26 this.fileData[normalizeFilename(fileName)] = content;

Callers 15

openMethod · 0.80
openMethod · 0.80
fileFunction · 0.80
_addColorOutputIntentFunction · 0.80
CourierFunction · 0.80
'Courier-Bold'Function · 0.80
'Courier-Oblique'Function · 0.80
'Courier-BoldOblique'Function · 0.80
HelveticaFunction · 0.80
'Helvetica-Bold'Function · 0.80
'Helvetica-Oblique'Function · 0.80
'Helvetica-BoldOblique'Function · 0.80

Calls 2

normalizeFilenameFunction · 0.85
toStringMethod · 0.45

Tested by 2

checkMissingFilesFunction · 0.64
createImageFunction · 0.64