fs.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. var fs = require("fs");
  2. var promisify = require("./_promisify.js");
  3. var bind = function(c, f) { return f && f.bind(c); };
  4. Object.defineProperties(module.exports, {
  5. F_OK: { enumerable: true, value: fs.F_OK },
  6. FileReadStream: { enumerable: true, value: fs.FileReadStream },
  7. FileWriteStream: { enumerable: true, value: fs.FileWriteStream },
  8. R_OK: { enumerable: true, value: fs.R_OK },
  9. ReadStream: { enumerable: true, value: fs.ReadStream },
  10. Stats: { enumerable: true, value: fs.Stats },
  11. W_OK: { enumerable: true, value: fs.W_OK },
  12. WriteStream: { enumerable: true, value: fs.WriteStream },
  13. X_OK: { enumerable: true, value: fs.X_OK },
  14. //_toUnixTimestamp: // skipping
  15. access: { enumerable: true, value: promisify(fs, fs.access, 1) },
  16. accessSync: { enumerable: true, value: bind(fs, fs.accessSync) },
  17. appendFile: { enumerable: true, value: promisify(fs, fs.appendFile, 2) },
  18. appendFileSync: { enumerable: true, value: bind(fs, fs.appendFileSync) },
  19. chmod: { enumerable: true, value: promisify(fs, fs.chmod, 2) },
  20. chmodSync: { enumerable: true, value: bind(fs, fs.chmodSync) },
  21. chown: { enumerable: true, value: promisify(fs, fs.chown, 3) },
  22. chownSync: { enumerable: true, value: bind(fs, fs.chownSync) },
  23. close: { enumerable: true, value: promisify(fs, fs.close, 1) },
  24. closeSync: { enumerable: true, value: bind(fs, fs.closeSync) },
  25. constants: { enumerable: true, get: function() { return fs.constants; }, set: function(v) { fs.constants = v; } },
  26. copyFile: { enumerable: true, value: promisify(fs, fs.copyFile, 2) },
  27. copyFileSync: { enumerable: true, value: bind(fs, fs.copyFileSync) },
  28. createReadStream: { enumerable: true, value: bind(fs, fs.createReadStream) },
  29. createWriteStream: { enumerable: true, value: bind(fs, fs.createWriteStream) },
  30. exists: { enumerable: true, value: promisify(fs, fs.exists, 1, {"noError":true}) },
  31. existsSync: { enumerable: true, value: bind(fs, fs.existsSync) },
  32. fchmod: { enumerable: true, value: promisify(fs, fs.fchmod, 2) },
  33. fchmodSync: { enumerable: true, value: bind(fs, fs.fchmodSync) },
  34. fchown: { enumerable: true, value: promisify(fs, fs.fchown, 3) },
  35. fchownSync: { enumerable: true, value: bind(fs, fs.fchownSync) },
  36. fdatasync: { enumerable: true, value: promisify(fs, fs.fdatasync, 1) },
  37. fdatasyncSync: { enumerable: true, value: bind(fs, fs.fdatasyncSync) },
  38. fstat: { enumerable: true, value: promisify(fs, fs.fstat, 1) },
  39. fstatSync: { enumerable: true, value: bind(fs, fs.fstatSync) },
  40. fsync: { enumerable: true, value: promisify(fs, fs.fsync, 1) },
  41. fsyncSync: { enumerable: true, value: bind(fs, fs.fsyncSync) },
  42. ftruncate: { enumerable: true, value: promisify(fs, fs.ftruncate, 2) },
  43. ftruncateSync: { enumerable: true, value: bind(fs, fs.ftruncateSync) },
  44. futimes: { enumerable: true, value: promisify(fs, fs.futimes, 3) },
  45. futimesSync: { enumerable: true, value: bind(fs, fs.futimesSync) },
  46. link: { enumerable: true, value: promisify(fs, fs.link, 2) },
  47. linkSync: { enumerable: true, value: bind(fs, fs.linkSync) },
  48. lstat: { enumerable: true, value: promisify(fs, fs.lstat, 1) },
  49. lstatSync: { enumerable: true, value: bind(fs, fs.lstatSync) },
  50. mkdir: { enumerable: true, value: promisify(fs, fs.mkdir, 1) },
  51. mkdirSync: { enumerable: true, value: bind(fs, fs.mkdirSync) },
  52. mkdtemp: { enumerable: true, value: promisify(fs, fs.mkdtemp, 1) },
  53. mkdtempSync: { enumerable: true, value: bind(fs, fs.mkdtempSync) },
  54. open: { enumerable: true, value: promisify(fs, fs.open, 2) },
  55. openSync: { enumerable: true, value: bind(fs, fs.openSync) },
  56. read: { enumerable: true, value: promisify(fs, fs.read, 5, {"pattern":["read","buffer"]}) },
  57. readFile: { enumerable: true, value: promisify(fs, fs.readFile, 1) },
  58. readFileSync: { enumerable: true, value: bind(fs, fs.readFileSync) },
  59. readSync: { enumerable: true, value: bind(fs, fs.readSync) },
  60. readdir: { enumerable: true, value: promisify(fs, fs.readdir, 1) },
  61. readdirSync: { enumerable: true, value: bind(fs, fs.readdirSync) },
  62. readlink: { enumerable: true, value: promisify(fs, fs.readlink, 1) },
  63. readlinkSync: { enumerable: true, value: bind(fs, fs.readlinkSync) },
  64. realpath: { enumerable: true, value: promisify(fs, fs.realpath, 1) },
  65. realpathSync: { enumerable: true, value: bind(fs, fs.realpathSync) },
  66. rename: { enumerable: true, value: promisify(fs, fs.rename, 2) },
  67. renameSync: { enumerable: true, value: bind(fs, fs.renameSync) },
  68. rmdir: { enumerable: true, value: promisify(fs, fs.rmdir, 1) },
  69. rmdirSync: { enumerable: true, value: bind(fs, fs.rmdirSync) },
  70. stat: { enumerable: true, value: promisify(fs, fs.stat, 1) },
  71. statSync: { enumerable: true, value: bind(fs, fs.statSync) },
  72. symlink: { enumerable: true, value: promisify(fs, fs.symlink, 2) },
  73. symlinkSync: { enumerable: true, value: bind(fs, fs.symlinkSync) },
  74. truncate: { enumerable: true, value: promisify(fs, fs.truncate, 2) },
  75. truncateSync: { enumerable: true, value: bind(fs, fs.truncateSync) },
  76. unlink: { enumerable: true, value: promisify(fs, fs.unlink, 1) },
  77. unlinkSync: { enumerable: true, value: bind(fs, fs.unlinkSync) },
  78. unwatchFile: { enumerable: true, value: bind(fs, fs.unwatchFile) },
  79. utimes: { enumerable: true, value: promisify(fs, fs.utimes, 3) },
  80. utimesSync: { enumerable: true, value: bind(fs, fs.utimesSync) },
  81. watch: { enumerable: true, value: bind(fs, fs.watch) },
  82. watchFile: { enumerable: true, value: bind(fs, fs.watchFile) },
  83. write: { enumerable: true, value: promisify(fs, fs.write, 5, {"pattern":["written","buffer"]}) },
  84. writeFile: { enumerable: true, value: promisify(fs, fs.writeFile, 2) },
  85. writeFileSync: { enumerable: true, value: bind(fs, fs.writeFileSync) },
  86. writeSync: { enumerable: true, value: bind(fs, fs.writeSync) },
  87. });