UNPKG

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