UNPKG

1.57 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var Errors_1 = require("./Errors");
4var Argument = /** @class */ (function () {
5 function Argument(group, parameterType) {
6 this.group = group;
7 this.parameterType = parameterType;
8 this.group = group;
9 this.parameterType = parameterType;
10 }
11 Argument.build = function (treeRegexp, text, parameterTypes) {
12 var group = treeRegexp.match(text);
13 if (!group) {
14 return null;
15 }
16 var argGroups = group.children;
17 if (argGroups.length !== parameterTypes.length) {
18 throw new Errors_1.CucumberExpressionError("Expression " + treeRegexp.regexp + " has " + argGroups.length + " capture groups (" + argGroups.map(function (g) { return g.value; }) + "), but there were " + parameterTypes.length + " parameter types (" + parameterTypes.map(function (p) { return p.name; }) + ")");
19 }
20 return parameterTypes.map(function (parameterType, i) { return new Argument(argGroups[i], parameterType); });
21 };
22 /**
23 * Get the value returned by the parameter type's transformer function.
24 *
25 * @param thisObj the object in which the transformer function is applied.
26 */
27 Argument.prototype.getValue = function (thisObj) {
28 var groupValues = this.group ? this.group.values : null;
29 return this.parameterType.transform(thisObj, groupValues);
30 };
31 return Argument;
32}());
33exports.default = Argument;
34module.exports = Argument;
35//# sourceMappingURL=Argument.js.map
\No newline at end of file