UNPKG

webpack-config

Version:

Helps to load, extend and merge webpack configs

91 lines (75 loc) 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _getIterator2 = require("babel-runtime/core-js/get-iterator"); var _getIterator3 = _interopRequireDefault(_getIterator2); var _weakMap = require("babel-runtime/core-js/weak-map"); var _weakMap2 = _interopRequireDefault(_weakMap); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * @private * @type {WeakMap} */ const COMMAND = new _weakMap2.default(); /** * @class */ class ConfigCommandInvoker { /** * @constructor * @param {ConfigCommand} command */ constructor(command) { COMMAND.set(this, command); } /** * @readonly * @type {ConfigCommand} */ get command() { return COMMAND.get(this); } /** * @param {Config} config * @param {...*} values * @returns {Config} */ invoke(config, ...values) { var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = (0, _getIterator3.default)(values), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { const value = _step.value; this.command.execute(config, value); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } return config; } /** * @param {String} name * @param {Config} config * @param {...*} values * @return {Config} */ static invoke(name, config, ...values) { const command = config.commandFactory.createCommand(name); return new ConfigCommandInvoker(command).invoke(config, ...values); } } exports.default = ConfigCommandInvoker; //# sourceMappingURL=ConfigCommandInvoker.js.map