You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.1 KiB

4 years ago
  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;