How to use the read function from graceful-fs

Find comprehensive JavaScript graceful-fs.read code examples handpicked from public code repositorys.

69
70
71
72
73
74
75
76
77
78
exports.read = function (fd, buffer, offset, length, position, callback) {
  if (typeof callback === 'function') {
    return fs.read(fd, buffer, offset, length, position, callback)
  }
  return new Promise((resolve, reject) => {
    fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
      if (err) return reject(err)
      resolve({ bytesRead, buffer })
    })
  })
fork icon808
star icon0
watch icon93

+ 41 other calls in file

70
71
72
73
74
75
76
77
78
79
  return new Promise(resolve => {
    return fs.exists(filename, resolve)
  })
}

// fs.read(), fs.write(), & fs.writev() need special treatment due to multiple callback args

exports.read = function (fd, buffer, offset, length, position, callback) {
  if (typeof callback === 'function') {
    return fs.read(fd, buffer, offset, length, position, callback)
fork icon806
star icon0
watch icon1

+ 29 other calls in file

68
69
70
71
72
73
74
75
76
77
78
79
  return new Promise(resolve => {
    return fs.exists(filename, resolve)
  })
}


// fs.read() & fs.write need special treatment due to multiple callback args


exports.read = function (fd, buffer, offset, length, position, callback) {
  if (typeof callback === 'function') {
    return fs.read(fd, buffer, offset, length, position, callback)
fork icon8
star icon3
watch icon0

+ 2 other calls in file