@cucumber/cucumber-expressions
Advanced tools
Comparing version 9.0.0 to 10.0.0
@@ -7,3 +7,3 @@ import TreeRegexp from './TreeRegexp'; | ||
readonly parameterType: ParameterType<T>; | ||
static build(treeRegexp: TreeRegexp, text: string, parameterTypes: Array<ParameterType<any>>): Array<Argument<any>>; | ||
static build(treeRegexp: TreeRegexp, text: string, parameterTypes: ReadonlyArray<ParameterType<any>>): ReadonlyArray<Argument<any>>; | ||
constructor(group: Group, parameterType: ParameterType<T>); | ||
@@ -10,0 +10,0 @@ /** |
@@ -7,4 +7,4 @@ import GeneratedExpression from './GeneratedExpression'; | ||
constructor(expressionTemplate: string, parameterTypeCombinations: Array<Array<ParameterType<any>>>); | ||
generateExpressions(): GeneratedExpression[]; | ||
generateExpressions(): ReadonlyArray<GeneratedExpression>; | ||
private generatePermutations; | ||
} |
@@ -18,3 +18,3 @@ import ParameterTypeRegistry from './ParameterTypeRegistry'; | ||
private processParameters; | ||
match(text: string): Array<Argument<any>>; | ||
match(text: string): ReadonlyArray<Argument<any>>; | ||
get regexp(): RegExp; | ||
@@ -21,0 +21,0 @@ get source(): string; |
@@ -6,3 +6,3 @@ import ParameterTypeRegistry from './ParameterTypeRegistry'; | ||
constructor(parameterTypeRegistry: ParameterTypeRegistry); | ||
generateExpressions(text: string): GeneratedExpression[]; | ||
generateExpressions(text: string): ReadonlyArray<GeneratedExpression>; | ||
/** | ||
@@ -9,0 +9,0 @@ * @deprecated |
@@ -6,6 +6,6 @@ import ParameterType from './ParameterType'; | ||
declare class AmbiguousParameterTypeError extends CucumberExpressionError { | ||
static forConstructor(keyName: string, keyValue: string, parameterTypes: Array<ParameterType<any>>, generatedExpressions: GeneratedExpression[]): AmbiguousParameterTypeError; | ||
static forRegExp(parameterTypeRegexp: string, expressionRegexp: RegExp, parameterTypes: Array<ParameterType<any>>, generatedExpressions: GeneratedExpression[]): AmbiguousParameterTypeError; | ||
static _parameterTypeNames(parameterTypes: Array<ParameterType<any>>): string; | ||
static _expressions(generatedExpressions: GeneratedExpression[]): string; | ||
static forConstructor(keyName: string, keyValue: string, parameterTypes: ReadonlyArray<ParameterType<any>>, generatedExpressions: ReadonlyArray<GeneratedExpression>): AmbiguousParameterTypeError; | ||
static forRegExp(parameterTypeRegexp: string, expressionRegexp: RegExp, parameterTypes: ReadonlyArray<ParameterType<any>>, generatedExpressions: ReadonlyArray<GeneratedExpression>): AmbiguousParameterTypeError; | ||
static _parameterTypeNames(parameterTypes: ReadonlyArray<ParameterType<any>>): string; | ||
static _expressions(generatedExpressions: ReadonlyArray<GeneratedExpression>): string; | ||
} | ||
@@ -12,0 +12,0 @@ declare class UndefinedParameterTypeError extends CucumberExpressionError { |
import Argument from './Argument'; | ||
export default interface Expression { | ||
readonly source: string; | ||
match(text: string): Array<Argument<any>>; | ||
match(text: string): ReadonlyArray<Argument<any>>; | ||
} |
import ParameterType from './ParameterType'; | ||
export default class GeneratedExpression { | ||
private readonly expressionTemplate; | ||
readonly parameterTypes: Array<ParameterType<any>>; | ||
constructor(expressionTemplate: string, parameterTypes: Array<ParameterType<any>>); | ||
readonly parameterTypes: ReadonlyArray<ParameterType<any>>; | ||
constructor(expressionTemplate: string, parameterTypes: ReadonlyArray<ParameterType<any>>); | ||
get source(): string; | ||
@@ -10,5 +10,5 @@ /** | ||
* | ||
* @returns {Array.<String>} | ||
* @returns {ReadonlyArray.<String>} | ||
*/ | ||
get parameterNames(): string[]; | ||
get parameterNames(): ReadonlyArray<string>; | ||
} |
@@ -43,3 +43,3 @@ "use strict"; | ||
* | ||
* @returns {Array.<String>} | ||
* @returns {ReadonlyArray.<String>} | ||
*/ | ||
@@ -46,0 +46,0 @@ get: function () { |
@@ -5,5 +5,5 @@ export default class Group { | ||
readonly end: number; | ||
readonly children: Group[]; | ||
constructor(value: string | null, start: number, end: number, children: Group[]); | ||
readonly children: ReadonlyArray<Group>; | ||
constructor(value: string | null, start: number, end: number, children: ReadonlyArray<Group>); | ||
get values(): string[]; | ||
} |
@@ -6,3 +6,3 @@ import Group from './Group'; | ||
capturing: boolean; | ||
private groupBuilders; | ||
private readonly groupBuilders; | ||
add(groupBuilder: GroupBuilder): void; | ||
@@ -9,0 +9,0 @@ build(match: RegexExecArray, nextGroupIndex: () => number): Group; |
@@ -9,3 +9,3 @@ export default class ParameterType<T> { | ||
static checkParameterTypeName(typeName: string): void; | ||
regexpStrings: string[]; | ||
regexpStrings: ReadonlyArray<string>; | ||
/** | ||
@@ -19,4 +19,4 @@ * @param name {String} the name of the type | ||
*/ | ||
constructor(name: string, regexps: RegExp[] | string[] | RegExp | string, type: any, transform: (...match: string[]) => T, useForSnippets: boolean, preferForRegexpMatch: boolean); | ||
constructor(name: string, regexps: ReadonlyArray<RegExp> | ReadonlyArray<string> | RegExp | string, type: any, transform: (...match: string[]) => T, useForSnippets: boolean, preferForRegexpMatch: boolean); | ||
transform(thisObj: any, groupValues: string[]): any; | ||
} |
@@ -1,4 +0,4 @@ | ||
export default interface RegexExecArray extends Array<string> { | ||
index: number[]; | ||
export default interface RegexExecArray extends ReadonlyArray<string> { | ||
index: ReadonlyArray<number>; | ||
input: string; | ||
} |
@@ -9,4 +9,4 @@ import Argument from './Argument'; | ||
constructor(regexp: RegExp, parameterTypeRegistry: ParameterTypeRegistry); | ||
match(text: string): Argument<any>[]; | ||
match(text: string): ReadonlyArray<Argument<any>>; | ||
get source(): string; | ||
} |
import GroupBuilder from './GroupBuilder'; | ||
import Group from './Group'; | ||
export default class TreeRegexp { | ||
@@ -7,3 +8,3 @@ regexp: RegExp; | ||
constructor(regexp: RegExp | string); | ||
match(s: string): import("./Group").default; | ||
match(s: string): Group | null; | ||
} |
@@ -79,3 +79,5 @@ 'use strict'; | ||
it('throws exception for illegal character in parameter name', function () { | ||
assert_1.default.throws(function () { return new ParameterType_1.default('[string]', /.*/, String, function (s) { return s; }, false, true); }, { message: "Illegal character '[' in parameter name {[string]}" }); | ||
assert_1.default.throws(function () { | ||
return new ParameterType_1.default('[string]', /.*/, String, function (s) { return s; }, false, true); | ||
}, { message: "Illegal character '[' in parameter name {[string]}" }); | ||
}); | ||
@@ -82,0 +84,0 @@ it('matches parameters with custom parameter type', function () { |
{ | ||
"name": "@cucumber/cucumber-expressions", | ||
"version": "9.0.0", | ||
"version": "10.0.0", | ||
"description": "Cucumber Expressions - a simpler alternative to Regular Expressions", | ||
@@ -32,18 +32,18 @@ "main": "dist/src/index.js", | ||
"devDependencies": { | ||
"@types/mocha": "^7.0.1", | ||
"@types/node": "^13.7.1", | ||
"@typescript-eslint/eslint-plugin": "^2.19.2", | ||
"@typescript-eslint/parser": "^2.19.2", | ||
"@types/mocha": "^7.0.2", | ||
"@types/node": "^13.9.8", | ||
"@typescript-eslint/eslint-plugin": "^2.26.0", | ||
"@typescript-eslint/parser": "^2.26.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.10.0", | ||
"eslint-plugin-node": "^11.0.0", | ||
"eslint-config-prettier": "^6.10.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"eslint-plugin-react": "^7.18.3", | ||
"mocha": "^7.0.1", | ||
"eslint-plugin-react": "^7.19.0", | ||
"mocha": "^7.1.1", | ||
"nyc": "^15.0.0", | ||
"prettier": "^1.19.1", | ||
"ts-loader": "^6.2.1", | ||
"ts-node": "^8.6.2", | ||
"typescript": "^3.7.5", | ||
"webpack": "^4.41.6", | ||
"prettier": "^2.0.2", | ||
"ts-loader": "^6.2.2", | ||
"ts-node": "^8.8.1", | ||
"typescript": "^3.8.3", | ||
"webpack": "^4.42.1", | ||
"webpack-cli": "^3.3.11" | ||
@@ -50,0 +50,0 @@ }, |
# Cucumber Expressions for JavaScript | ||
[![Build Status](https://travis-ci.org/cucumber/cucumber-expressions-javascript.svg?branch=master)](https://travis-ci.org/cucumber/cucumber-expressions-javascript) | ||
[The docs are here](https://cucumber.io/docs/cucumber/cucumber-expressions/). |
@@ -10,4 +10,4 @@ import TreeRegexp from './TreeRegexp' | ||
text: string, | ||
parameterTypes: Array<ParameterType<any>> | ||
): Array<Argument<any>> { | ||
parameterTypes: ReadonlyArray<ParameterType<any>> | ||
): ReadonlyArray<Argument<any>> { | ||
const group = treeRegexp.match(text) | ||
@@ -24,5 +24,5 @@ if (!group) { | ||
argGroups.length | ||
} capture groups (${argGroups.map(g => g.value)}), but there were ${ | ||
} capture groups (${argGroups.map((g) => g.value)}), but there were ${ | ||
parameterTypes.length | ||
} parameter types (${parameterTypes.map(p => p.name)})` | ||
} parameter types (${parameterTypes.map((p) => p.name)})` | ||
) | ||
@@ -29,0 +29,0 @@ } |
@@ -15,3 +15,3 @@ import GeneratedExpression from './GeneratedExpression' | ||
public generateExpressions() { | ||
public generateExpressions(): ReadonlyArray<GeneratedExpression> { | ||
const generatedExpressions: GeneratedExpression[] = [] | ||
@@ -18,0 +18,0 @@ this.generatePermutations(generatedExpressions, 0, []) |
@@ -62,3 +62,3 @@ import ParameterTypeRegistry from './ParameterTypeRegistry' | ||
ALTERNATIVE_NON_WHITESPACE_TEXT_REGEXP(), | ||
match => { | ||
(match) => { | ||
// replace \/ with / | ||
@@ -102,3 +102,3 @@ // replace / with | | ||
public match(text: string): Array<Argument<any>> { | ||
public match(text: string): ReadonlyArray<Argument<any>> { | ||
return Argument.build(this.treeRegexp, text, this.parameterTypes) | ||
@@ -111,3 +111,3 @@ } | ||
get source() { | ||
get source(): string { | ||
return this.expression | ||
@@ -123,3 +123,3 @@ } | ||
function buildCaptureRegexp(regexps: string[]) { | ||
function buildCaptureRegexp(regexps: ReadonlyArray<string>) { | ||
if (regexps.length === 1) { | ||
@@ -129,3 +129,3 @@ return `(${regexps[0]})` | ||
const captureGroups = regexps.map(group => { | ||
const captureGroups = regexps.map((group) => { | ||
return `(?:${group})` | ||
@@ -132,0 +132,0 @@ }) |
@@ -12,3 +12,3 @@ import ParameterTypeRegistry from './ParameterTypeRegistry' | ||
public generateExpressions(text: string): GeneratedExpression[] { | ||
public generateExpressions(text: string): ReadonlyArray<GeneratedExpression> { | ||
const parameterTypeCombinations: Array<Array<ParameterType<any>>> = [] | ||
@@ -38,3 +38,3 @@ const parameterTypeMatchers = this.createParameterTypeMatchers(text) | ||
const bestParameterTypeMatchers = matchingParameterTypeMatchers.filter( | ||
m => ParameterTypeMatcher.compare(m, bestParameterTypeMatcher) === 0 | ||
(m) => ParameterTypeMatcher.compare(m, bestParameterTypeMatcher) === 0 | ||
) | ||
@@ -41,0 +41,0 @@ |
@@ -10,4 +10,4 @@ import ParameterType from './ParameterType' | ||
keyValue: string, | ||
parameterTypes: Array<ParameterType<any>>, | ||
generatedExpressions: GeneratedExpression[] | ||
parameterTypes: ReadonlyArray<ParameterType<any>>, | ||
generatedExpressions: ReadonlyArray<GeneratedExpression> | ||
) { | ||
@@ -22,4 +22,4 @@ return new this( | ||
expressionRegexp: RegExp, | ||
parameterTypes: Array<ParameterType<any>>, | ||
generatedExpressions: GeneratedExpression[] | ||
parameterTypes: ReadonlyArray<ParameterType<any>>, | ||
generatedExpressions: ReadonlyArray<GeneratedExpression> | ||
) { | ||
@@ -41,8 +41,12 @@ return new this( | ||
public static _parameterTypeNames(parameterTypes: Array<ParameterType<any>>) { | ||
return parameterTypes.map(p => `{${p.name}}`).join('\n ') | ||
public static _parameterTypeNames( | ||
parameterTypes: ReadonlyArray<ParameterType<any>> | ||
) { | ||
return parameterTypes.map((p) => `{${p.name}}`).join('\n ') | ||
} | ||
public static _expressions(generatedExpressions: GeneratedExpression[]) { | ||
return generatedExpressions.map(e => e.source).join('\n ') | ||
public static _expressions( | ||
generatedExpressions: ReadonlyArray<GeneratedExpression> | ||
) { | ||
return generatedExpressions.map((e) => e.source).join('\n ') | ||
} | ||
@@ -49,0 +53,0 @@ } |
@@ -5,3 +5,3 @@ import Argument from './Argument' | ||
readonly source: string | ||
match(text: string): Array<Argument<any>> | ||
match(text: string): ReadonlyArray<Argument<any>> | ||
} |
@@ -7,3 +7,3 @@ import util from 'util' | ||
private readonly expressionTemplate: string, | ||
public readonly parameterTypes: Array<ParameterType<any>> | ||
public readonly parameterTypes: ReadonlyArray<ParameterType<any>> | ||
) {} | ||
@@ -14,3 +14,3 @@ | ||
this.expressionTemplate, | ||
...this.parameterTypes.map(t => t.name) | ||
...this.parameterTypes.map((t) => t.name) | ||
) | ||
@@ -22,7 +22,7 @@ } | ||
* | ||
* @returns {Array.<String>} | ||
* @returns {ReadonlyArray.<String>} | ||
*/ | ||
get parameterNames() { | ||
get parameterNames(): ReadonlyArray<string> { | ||
const usageByTypeName: { [key: string]: number } = {} | ||
return this.parameterTypes.map(t => | ||
return this.parameterTypes.map((t) => | ||
getParameterName(t.name, usageByTypeName) | ||
@@ -29,0 +29,0 @@ ) |
@@ -6,3 +6,3 @@ export default class Group { | ||
public readonly end: number, | ||
public readonly children: Group[] | ||
public readonly children: ReadonlyArray<Group> | ||
) {} | ||
@@ -12,5 +12,5 @@ | ||
return (this.children.length === 0 ? [this] : this.children) | ||
.filter(g => typeof g.start !== 'undefined') | ||
.map(g => g.value) | ||
.filter((g) => typeof g.start !== 'undefined') | ||
.map((g) => g.value) | ||
} | ||
} |
@@ -7,3 +7,3 @@ import Group from './Group' | ||
public capturing = true | ||
private groupBuilders: GroupBuilder[] = [] | ||
private readonly groupBuilders: GroupBuilder[] = [] | ||
@@ -16,3 +16,3 @@ public add(groupBuilder: GroupBuilder) { | ||
const groupIndex = nextGroupIndex() | ||
const children = this.groupBuilders.map(gb => | ||
const children = this.groupBuilders.map((gb) => | ||
gb.build(match, nextGroupIndex) | ||
@@ -37,4 +37,4 @@ ) | ||
public moveChildrenTo(groupBuilder: GroupBuilder) { | ||
this.groupBuilders.forEach(child => groupBuilder.add(child)) | ||
this.groupBuilders.forEach((child) => groupBuilder.add(child)) | ||
} | ||
} |
@@ -7,3 +7,3 @@ import { CucumberExpressionError } from './Errors' | ||
export default class ParameterType<T> { | ||
private transformFn: (...match: string[]) => T | ||
private transformFn: (...match: ReadonlyArray<string>) => T | ||
@@ -30,3 +30,3 @@ public static compare(pt1: ParameterType<any>, pt2: ParameterType<any>) { | ||
public regexpStrings: string[] | ||
public regexpStrings: ReadonlyArray<string> | ||
@@ -43,3 +43,3 @@ /** | ||
public readonly name: string, | ||
regexps: RegExp[] | string[] | RegExp | string, | ||
regexps: ReadonlyArray<RegExp> | ReadonlyArray<string> | RegExp | string, | ||
private readonly type: any, | ||
@@ -51,3 +51,3 @@ transform: (...match: string[]) => T, | ||
if (transform === undefined) { | ||
transform = s => (s as unknown) as T | ||
transform = (s) => (s as unknown) as T | ||
} | ||
@@ -74,3 +74,5 @@ if (useForSnippets === undefined) { | ||
function stringArray(regexps: RegExp[] | string[] | RegExp | string): string[] { | ||
function stringArray( | ||
regexps: ReadonlyArray<RegExp> | ReadonlyArray<string> | RegExp | string | ||
): string[] { | ||
const array = Array.isArray(regexps) ? regexps : [regexps] | ||
@@ -77,0 +79,0 @@ return array.map((r: RegExp | string) => |
@@ -25,3 +25,3 @@ import ParameterType from './ParameterType' | ||
Number, | ||
s => (s === undefined ? null : Number(s)), | ||
(s) => (s === undefined ? null : Number(s)), | ||
true, | ||
@@ -36,3 +36,3 @@ true | ||
Number, | ||
s => (s === undefined ? null : parseFloat(s)), | ||
(s) => (s === undefined ? null : parseFloat(s)), | ||
true, | ||
@@ -47,3 +47,3 @@ false | ||
String, | ||
s => s, | ||
(s) => s, | ||
false, | ||
@@ -58,3 +58,3 @@ false | ||
String, | ||
s => (s || '').replace(/\\"/g, '"').replace(/\\'/g, "'"), | ||
(s) => (s || '').replace(/\\"/g, '"').replace(/\\'/g, "'"), | ||
true, | ||
@@ -69,3 +69,3 @@ false | ||
String, | ||
s => s, | ||
(s) => s, | ||
false, | ||
@@ -72,0 +72,0 @@ true |
@@ -1,4 +0,4 @@ | ||
export default interface RegexExecArray extends Array<string> { | ||
index: number[] | ||
export default interface RegexExecArray extends ReadonlyArray<string> { | ||
index: ReadonlyArray<number> | ||
input: string | ||
} |
@@ -17,5 +17,5 @@ import Argument from './Argument' | ||
public match(text: string) { | ||
public match(text: string): ReadonlyArray<Argument<any>> { | ||
const parameterTypes = this.treeRegexp.groupBuilder.children.map( | ||
groupBuilder => { | ||
(groupBuilder) => { | ||
const parameterTypeRegexp = groupBuilder.source | ||
@@ -33,3 +33,3 @@ | ||
String, | ||
s => (s === undefined ? null : s), | ||
(s) => (s === undefined ? null : s), | ||
false, | ||
@@ -45,5 +45,5 @@ false | ||
get source() { | ||
get source(): string { | ||
return this.regexp.source | ||
} | ||
} |
@@ -5,2 +5,3 @@ import GroupBuilder from './GroupBuilder' | ||
import RegexExecArray from './RegexExecArray' | ||
import Group from './Group' | ||
@@ -56,3 +57,3 @@ export default class TreeRegexp { | ||
public match(s: string) { | ||
public match(s: string): Group | null { | ||
const match: RegexExecArray = this.regex.exec(s) | ||
@@ -59,0 +60,0 @@ if (!match) { |
@@ -13,3 +13,3 @@ import assert from 'assert' | ||
null, | ||
s => s, | ||
(s) => s, | ||
false, | ||
@@ -22,3 +22,3 @@ true | ||
null, | ||
s => s, | ||
(s) => s, | ||
false, | ||
@@ -33,3 +33,3 @@ true | ||
null, | ||
s => s, | ||
(s) => s, | ||
false, | ||
@@ -42,3 +42,3 @@ true | ||
null, | ||
s => s, | ||
(s) => s, | ||
false, | ||
@@ -51,3 +51,3 @@ true | ||
null, | ||
s => s, | ||
(s) => s, | ||
false, | ||
@@ -63,3 +63,3 @@ true | ||
) | ||
const expressions = factory.generateExpressions().map(ge => ge.source) | ||
const expressions = factory.generateExpressions().map((ge) => ge.source) | ||
assert.deepStrictEqual(expressions, [ | ||
@@ -66,0 +66,0 @@ 'I bought a {color} ball on {date}', |
@@ -118,3 +118,3 @@ import assert from 'assert' | ||
Currency, | ||
s => new Currency(s), | ||
(s) => new Currency(s), | ||
true, | ||
@@ -138,3 +138,3 @@ false | ||
Currency, | ||
s => new Currency(s), | ||
(s) => new Currency(s), | ||
true, | ||
@@ -145,3 +145,3 @@ false | ||
parameterTypeRegistry.defineParameterType( | ||
new ParameterType('date', /b c/, Date, s => new Date(s), true, false) | ||
new ParameterType('date', /b c/, Date, (s) => new Date(s), true, false) | ||
) | ||
@@ -160,3 +160,3 @@ | ||
null, | ||
s => new Currency(s), | ||
(s) => new Currency(s), | ||
true, | ||
@@ -167,3 +167,3 @@ false | ||
parameterTypeRegistry.defineParameterType( | ||
new ParameterType('date', /x/, null, s => new Date(s), true, false) | ||
new ParameterType('date', /x/, null, (s) => new Date(s), true, false) | ||
) | ||
@@ -174,3 +174,3 @@ | ||
) | ||
const expressions = generatedExpressions.map(e => e.source) | ||
const expressions = generatedExpressions.map((e) => e.source) | ||
assert.deepStrictEqual(expressions, [ | ||
@@ -192,3 +192,5 @@ 'I have {currency} and {currency} and another {currency}', | ||
)[0] | ||
const typeNames = expression.parameterTypes.map(parameter => parameter.name) | ||
const typeNames = expression.parameterTypes.map( | ||
(parameter) => parameter.name | ||
) | ||
assert.deepStrictEqual(typeNames, ['int', 'float']) | ||
@@ -203,3 +205,3 @@ }) | ||
null, | ||
s => s, | ||
(s) => s, | ||
true, | ||
@@ -214,3 +216,3 @@ false | ||
null, | ||
s => s, | ||
(s) => s, | ||
true, | ||
@@ -239,3 +241,3 @@ false | ||
null, | ||
s => s, | ||
(s) => s, | ||
true, | ||
@@ -253,6 +255,6 @@ false | ||
parameterTypeRegistry.defineParameterType( | ||
new ParameterType('zero-or-more', /[a-z]*/, null, s => s, true, false) | ||
new ParameterType('zero-or-more', /[a-z]*/, null, (s) => s, true, false) | ||
) | ||
parameterTypeRegistry.defineParameterType( | ||
new ParameterType('exactly-one', /[a-z]/, null, s => s, true, false) | ||
new ParameterType('exactly-one', /[a-z]/, null, (s) => s, true, false) | ||
) | ||
@@ -274,3 +276,3 @@ | ||
parameterTypeRegistry.defineParameterType( | ||
new ParameterType('direction', /(up|down)/, null, s => s, true, false) | ||
new ParameterType('direction', /(up|down)/, null, (s) => s, true, false) | ||
) | ||
@@ -286,3 +288,3 @@ | ||
parameterTypeRegistry.defineParameterType( | ||
new ParameterType('direction', /(up|down)/, null, s => s, true, false) | ||
new ParameterType('direction', /(up|down)/, null, (s) => s, true, false) | ||
) | ||
@@ -298,3 +300,3 @@ | ||
parameterTypeRegistry.defineParameterType( | ||
new ParameterType('direction', /(up|down)/, null, s => s, true, false) | ||
new ParameterType('direction', /(up|down)/, null, (s) => s, true, false) | ||
) | ||
@@ -310,3 +312,3 @@ | ||
parameterTypeRegistry.defineParameterType( | ||
new ParameterType('direction', /(up|down)/, null, s => s, true, false) | ||
new ParameterType('direction', /(up|down)/, null, (s) => s, true, false) | ||
) | ||
@@ -333,3 +335,3 @@ | ||
parameterTypeRegistry.defineParameterType( | ||
new ParameterType('direction', /(up|down)/, null, s => s, true, false) | ||
new ParameterType('direction', /(up|down)/, null, (s) => s, true, false) | ||
) | ||
@@ -336,0 +338,0 @@ |
@@ -265,3 +265,3 @@ import assert from 'assert' | ||
null, | ||
function(s: string) { | ||
function (s: string) { | ||
return this.createWidget(s) | ||
@@ -289,13 +289,15 @@ }, | ||
describe('escapes special characters', () => { | ||
;['\\', '[', ']', '^', '$', '.', '|', '?', '*', '+'].forEach(character => { | ||
it(`escapes ${character}`, () => { | ||
const expr = `I have {int} cuke(s) and ${character}` | ||
const expression = new CucumberExpression( | ||
expr, | ||
new ParameterTypeRegistry() | ||
) | ||
const arg1 = expression.match(`I have 800 cukes and ${character}`)[0] | ||
assert.strictEqual(arg1.getValue(null), 800) | ||
}) | ||
}) | ||
;['\\', '[', ']', '^', '$', '.', '|', '?', '*', '+'].forEach( | ||
(character) => { | ||
it(`escapes ${character}`, () => { | ||
const expr = `I have {int} cuke(s) and ${character}` | ||
const expression = new CucumberExpression( | ||
expr, | ||
new ParameterTypeRegistry() | ||
) | ||
const arg1 = expression.match(`I have 800 cukes and ${character}`)[0] | ||
assert.strictEqual(arg1.getValue(null), 800) | ||
}) | ||
} | ||
) | ||
@@ -336,3 +338,3 @@ it(`escapes .`, () => { | ||
} | ||
return args.map(arg => arg.getValue(null)) | ||
return args.map((arg) => arg.getValue(null)) | ||
} |
@@ -43,3 +43,4 @@ 'use strict' | ||
assert.throws( | ||
() => new ParameterType('[string]', /.*/, String, s => s, false, true), | ||
() => | ||
new ParameterType('[string]', /.*/, String, (s) => s, false, true), | ||
{ message: "Illegal character '[' in parameter name {[string]}" } | ||
@@ -105,3 +106,3 @@ ) | ||
Color, | ||
s => new Color(s), | ||
(s) => new Color(s), | ||
false, | ||
@@ -125,3 +126,3 @@ true | ||
null, | ||
s => { | ||
(s) => { | ||
throw new Error(`Can't transform [${s}]`) | ||
@@ -153,3 +154,3 @@ }, | ||
CssColor, | ||
s => new CssColor(s), | ||
(s) => new CssColor(s), | ||
false, | ||
@@ -169,3 +170,3 @@ true | ||
Color, | ||
s => new Color(s), | ||
(s) => new Color(s), | ||
false, | ||
@@ -183,3 +184,3 @@ false | ||
CssColor, | ||
s => new CssColor(s), | ||
(s) => new CssColor(s), | ||
true, | ||
@@ -232,3 +233,3 @@ false | ||
Color, | ||
async s => new Color(s), | ||
async (s) => new Color(s), | ||
false, | ||
@@ -235,0 +236,0 @@ true |
@@ -17,3 +17,3 @@ import fs from 'fs' | ||
} | ||
return args.map(arg => arg.getValue(null)) | ||
return args.map((arg) => arg.getValue(null)) | ||
} | ||
@@ -20,0 +20,0 @@ |
@@ -29,3 +29,3 @@ import assert from 'assert' | ||
Name, | ||
s => new Name(s), | ||
(s) => new Name(s), | ||
true, | ||
@@ -40,3 +40,3 @@ true | ||
Person, | ||
s => new Person(s), | ||
(s) => new Person(s), | ||
true, | ||
@@ -52,3 +52,3 @@ false | ||
Place, | ||
s => new Place(s), | ||
(s) => new Place(s), | ||
true, | ||
@@ -72,3 +72,3 @@ true | ||
null, | ||
s => new Name(s), | ||
(s) => new Name(s), | ||
true, | ||
@@ -81,3 +81,3 @@ false | ||
null, | ||
s => new Person(s), | ||
(s) => new Person(s), | ||
true, | ||
@@ -90,3 +90,3 @@ true | ||
null, | ||
s => new Place(s), | ||
(s) => new Place(s), | ||
true, | ||
@@ -93,0 +93,0 @@ false |
@@ -12,3 +12,3 @@ import ParameterType from '../src/ParameterType' | ||
String, | ||
s => s, | ||
(s) => s, | ||
true, | ||
@@ -15,0 +15,0 @@ true |
@@ -108,3 +108,3 @@ import assert from 'assert' | ||
it('does not take consider parenthesis in character class as group', function() { | ||
it('does not take consider parenthesis in character class as group', function () { | ||
const expression = new RegularExpression( | ||
@@ -127,3 +127,3 @@ /^drawings: ([A-Z_, ()]+)$/, | ||
} | ||
return args.map(arg => arg.getValue(null)) | ||
return args.map((arg) => arg.getValue(null)) | ||
} |
@@ -8,3 +8,3 @@ import assert from 'assert' | ||
assert.deepStrictEqual( | ||
tr.groupBuilder.children.map(gb => gb.source), | ||
tr.groupBuilder.children.map((gb) => gb.source), | ||
['a(?:b)?', 'c'] | ||
@@ -11,0 +11,0 @@ ) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
588714
11780
4