MCPcopy Create free account
hub / github.com/github/docs / getBuffer

Function getBuffer

middleware/favicons.js:22–36  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

20}
21
22function getBuffer(filePath) {
23 let buffer
24 if (!fs.existsSync(filePath)) {
25 throw new Error(`${filePath} not found on disk`)
26 }
27 return () => {
28 if (!buffer) {
29 // Yes, sync and a bit slow, but the headers we send will
30 // make sure these requests are rare because the payload
31 // will be sticky in the CDN and stickly in the browser too.
32 buffer = fs.readFileSync(filePath)
33 }
34 return buffer
35 }
36}
37
38export default function favicons(req, res, next) {
39 if (!MAP[req.path]) return next()

Callers 1

favicons.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected