lib/file/access/index.js
function readableBy(file, user) {
  if (!exists(file)) {
    return readableBy(path.dirname(file), user);
  }
  const userData = findUser(user);
  if (userData.id === 0) {
    return true;
  } else if (userData.id === process.getuid()) {
    return readable(file);
  } else {
    return _accesibleByUser(userData, file, fs.R_OK);
  }
}
function readableBy(file, user) {
  if (!exists(file)) {
    return readableBy(path.dirname(file), user);
  }
  const userData = findUser(user);
  if (userData.id === 0) {
    return true;
  } else if (userData.id === process.getuid()) {
    return readable(file);
  } else {
    return _accesibleByUser(userData, file, fs.R_OK);
  }
}
function readableBy ( file , user ) { if ( ! exists ( file ) ) { return readableBy ( path . dirname ( file ) , user ) ; } const userData = findUser ( user ) ; if ( userData . id === 0 ) { return true ; } else if ( userData . id === process . getuid ( ) ) { return readable ( file ) ; } else { return _accesibleByUser ( userData , file , fs . R_OK ) ; } }
Check whether a file is readable or not by a given user
@function $file~readableBy
@param {string} file
@param {string|number} user - Username or user id to check permissions for
@returns {boolean}
@example
// Check if 'conf/my.cnf' is readable by the 'nobody' user
$file.readableBy('conf/my.cnf', 'nobody');
// => false
Check whether a file is readable or not by a given user