import $ from 'jquery';
import Utils from './utils';
var convertArrayRequirement = function(string, length) {
var m = string.match(/^\s*\[(.*)\]\s*$/);
if (!m)
throw 'Requirement is not an array: "' + string + '"';
var values = m[1].split(',').map(Utils.trimString);
if (values.length !== length)
throw 'Requirement has ' + values.length + ' values when ' + length + ' are needed';
return values;
};
var convertExtraOptionRequirement = function(requirementSpec, string, extraOptionReader) {
var main = null;
var extra = {};
for (var key in requirementSpec) {
if (key) {
var value = extraOptionReader(key);
if ('string' === typeof value)
value = Utils.parseRequirement(requirementSpec[key], value);
extra[key] = value;
} else {
main = Utils.parseRequirement(requirementSpec[key], string);
}
}
return [main, extra];
};