/usr/lib/nodejs/fs-exists-cached/index.js is in node-tap 11.0.0+ds1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | module.exports = exists
exists.sync = sync
var fs = require('fs')
var existsCache = Object.create(null)
function exists (file, cb) {
if (file in existsCache)
return process.nextTick(cb.bind(null, existsCache[file]))
fs.lstat(file, function (er) {
cb(existsCache[file] = !er)
})
}
function sync (file) {
if (file in existsCache)
return existsCache[file]
try {
fs.lstatSync(file)
existsCache[file] = true
} catch (er) {
existsCache[file] = false
}
return existsCache[file]
}
|