index.js 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const optionsManager = require("./managers/options");
  4. const statProvider = require("./providers/stat");
  5. /**
  6. * Asynchronous API.
  7. */
  8. function stat(path, opts) {
  9. return new Promise((resolve, reject) => {
  10. statProvider.async(path, optionsManager.prepare(opts), (err, stats) => err ? reject(err) : resolve(stats));
  11. });
  12. }
  13. exports.stat = stat;
  14. function statCallback(path, optsOrCallback, callback) {
  15. if (typeof optsOrCallback === 'function') {
  16. callback = optsOrCallback; /* tslint:disable-line: no-parameter-reassignment */
  17. optsOrCallback = undefined; /* tslint:disable-line: no-parameter-reassignment */
  18. }
  19. if (typeof callback === 'undefined') {
  20. throw new TypeError('The "callback" argument must be of type Function.');
  21. }
  22. statProvider.async(path, optionsManager.prepare(optsOrCallback), callback);
  23. }
  24. exports.statCallback = statCallback;
  25. /**
  26. * Synchronous API.
  27. */
  28. function statSync(path, opts) {
  29. return statProvider.sync(path, optionsManager.prepare(opts));
  30. }
  31. exports.statSync = statSync;