virtual-stats.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.VirtualStats = void 0;
  7. const constants_1 = __importDefault(require("constants"));
  8. class VirtualStats {
  9. constructor(config) {
  10. for (const key in config) {
  11. if (!Object.prototype.hasOwnProperty.call(config, key)) {
  12. continue;
  13. }
  14. this[key] = config[key];
  15. }
  16. }
  17. _checkModeProperty(property) {
  18. return (this.mode & constants_1.default.S_IFMT) === property;
  19. }
  20. isDirectory() {
  21. return this._checkModeProperty(constants_1.default.S_IFDIR);
  22. }
  23. isFile() {
  24. return this._checkModeProperty(constants_1.default.S_IFREG);
  25. }
  26. isBlockDevice() {
  27. return this._checkModeProperty(constants_1.default.S_IFBLK);
  28. }
  29. isCharacterDevice() {
  30. return this._checkModeProperty(constants_1.default.S_IFCHR);
  31. }
  32. isSymbolicLink() {
  33. return this._checkModeProperty(constants_1.default.S_IFLNK);
  34. }
  35. isFIFO() {
  36. return this._checkModeProperty(constants_1.default.S_IFIFO);
  37. }
  38. isSocket() {
  39. return this._checkModeProperty(constants_1.default.S_IFSOCK);
  40. }
  41. }
  42. exports.VirtualStats = VirtualStats;
  43. //# sourceMappingURL=virtual-stats.js.map