index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createConfigItem = createConfigItem;
  6. exports.createConfigItemSync = exports.createConfigItemAsync = void 0;
  7. Object.defineProperty(exports, "default", {
  8. enumerable: true,
  9. get: function () {
  10. return _full.default;
  11. }
  12. });
  13. exports.loadPartialConfigSync = exports.loadPartialConfigAsync = exports.loadPartialConfig = exports.loadOptionsSync = exports.loadOptionsAsync = exports.loadOptions = void 0;
  14. function _gensync() {
  15. const data = require("gensync");
  16. _gensync = function () {
  17. return data;
  18. };
  19. return data;
  20. }
  21. var _full = require("./full");
  22. var _partial = require("./partial");
  23. var _item = require("./item");
  24. const loadOptionsRunner = _gensync()(function* (opts) {
  25. var _config$options;
  26. const config = yield* (0, _full.default)(opts);
  27. return (_config$options = config == null ? void 0 : config.options) != null ? _config$options : null;
  28. });
  29. const createConfigItemRunner = _gensync()(_item.createConfigItem);
  30. const maybeErrback = runner => (opts, callback) => {
  31. if (callback === undefined && typeof opts === "function") {
  32. callback = opts;
  33. opts = undefined;
  34. }
  35. return callback ? runner.errback(opts, callback) : runner.sync(opts);
  36. };
  37. const loadPartialConfig = maybeErrback(_partial.loadPartialConfig);
  38. exports.loadPartialConfig = loadPartialConfig;
  39. const loadPartialConfigSync = _partial.loadPartialConfig.sync;
  40. exports.loadPartialConfigSync = loadPartialConfigSync;
  41. const loadPartialConfigAsync = _partial.loadPartialConfig.async;
  42. exports.loadPartialConfigAsync = loadPartialConfigAsync;
  43. const loadOptions = maybeErrback(loadOptionsRunner);
  44. exports.loadOptions = loadOptions;
  45. const loadOptionsSync = loadOptionsRunner.sync;
  46. exports.loadOptionsSync = loadOptionsSync;
  47. const loadOptionsAsync = loadOptionsRunner.async;
  48. exports.loadOptionsAsync = loadOptionsAsync;
  49. const createConfigItemSync = createConfigItemRunner.sync;
  50. exports.createConfigItemSync = createConfigItemSync;
  51. const createConfigItemAsync = createConfigItemRunner.async;
  52. exports.createConfigItemAsync = createConfigItemAsync;
  53. function createConfigItem(target, options, callback) {
  54. if (callback !== undefined) {
  55. return createConfigItemRunner.errback(target, options, callback);
  56. } else if (typeof options === "function") {
  57. return createConfigItemRunner.errback(target, undefined, callback);
  58. } else {
  59. return createConfigItemRunner.sync(target, options);
  60. }
  61. }