@cucumber/cucumber-expressions
Advanced tools
Comparing version 12.1.1 to 12.1.2
{ | ||
"name": "@cucumber/cucumber-expressions", | ||
"version": "12.1.1", | ||
"version": "12.1.2", | ||
"description": "Cucumber Expressions - a simpler alternative to Regular Expressions", | ||
@@ -28,12 +28,12 @@ "main": "dist/src/index.js", | ||
"devDependencies": { | ||
"@types/js-yaml": "^4.0.0", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^14.14.37", | ||
"js-yaml": "^4.0.0", | ||
"mocha": "^8.3.2", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.2.3" | ||
"@types/js-yaml": "4.0.2", | ||
"@types/mocha": "9.0.0", | ||
"@types/node": "16.6.1", | ||
"js-yaml": "4.1.0", | ||
"mocha": "9.0.3", | ||
"ts-node": "10.2.0", | ||
"typescript": "4.3.5" | ||
}, | ||
"dependencies": { | ||
"becke-ch--regex--s0-0-v1--base--pl--lib": "^1.4.0" | ||
"becke-ch--regex--s0-0-v1--base--pl--lib": "1.4.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "directories": { |
@@ -7,3 +7,3 @@ import TreeRegexp from './TreeRegexp'; | ||
readonly parameterType: ParameterType<T>; | ||
static build(treeRegexp: TreeRegexp, text: string, parameterTypes: ReadonlyArray<ParameterType<any>>): ReadonlyArray<Argument<any>>; | ||
static build(treeRegexp: TreeRegexp, text: string, parameterTypes: readonly ParameterType<any>[]): readonly Argument<any>[]; | ||
constructor(group: Group, parameterType: ParameterType<T>); | ||
@@ -10,0 +10,0 @@ /** |
@@ -9,7 +9,7 @@ export declare function symbolOf(token: TokenType): string; | ||
readonly type: NodeType; | ||
readonly nodes?: ReadonlyArray<Node> | undefined; | ||
readonly nodes?: readonly Node[] | undefined; | ||
readonly token?: string | undefined; | ||
readonly start: number; | ||
readonly end: number; | ||
constructor(type: NodeType, nodes: ReadonlyArray<Node>, token: string, start: number, end: number); | ||
constructor(type: NodeType, nodes: readonly Node[], token: string, start: number, end: number); | ||
text(): string; | ||
@@ -16,0 +16,0 @@ } |
@@ -7,5 +7,5 @@ import GeneratedExpression from './GeneratedExpression'; | ||
constructor(expressionTemplate: string, parameterTypeCombinations: Array<Array<ParameterType<any>>>); | ||
generateExpressions(): ReadonlyArray<GeneratedExpression>; | ||
generateExpressions(): readonly GeneratedExpression[]; | ||
private generatePermutations; | ||
} | ||
//# sourceMappingURL=CombinatorialGeneratedExpressionFactory.d.ts.map |
@@ -24,3 +24,3 @@ import ParameterTypeRegistry from './ParameterTypeRegistry'; | ||
private assertNoOptionals; | ||
match(text: string): ReadonlyArray<Argument<any>>; | ||
match(text: string): readonly Argument<any>[]; | ||
get regexp(): RegExp; | ||
@@ -27,0 +27,0 @@ get source(): string; |
@@ -6,3 +6,3 @@ import ParameterType from './ParameterType'; | ||
constructor(parameterTypes: () => Iterable<ParameterType<any>>); | ||
generateExpressions(text: string): ReadonlyArray<GeneratedExpression>; | ||
generateExpressions(text: string): readonly GeneratedExpression[]; | ||
/** | ||
@@ -9,0 +9,0 @@ * @deprecated |
import { Token } from './Ast'; | ||
export default class CucumberExpressionTokenizer { | ||
tokenize(expression: string): ReadonlyArray<Token>; | ||
tokenize(expression: string): readonly Token[]; | ||
} | ||
//# sourceMappingURL=CucumberExpressionTokenizer.d.ts.map |
@@ -16,6 +16,6 @@ import ParameterType from './ParameterType'; | ||
export declare class AmbiguousParameterTypeError extends CucumberExpressionError { | ||
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; | ||
static forConstructor(keyName: string, keyValue: string, parameterTypes: readonly ParameterType<any>[], generatedExpressions: readonly GeneratedExpression[]): AmbiguousParameterTypeError; | ||
static forRegExp(parameterTypeRegexp: string, expressionRegexp: RegExp, parameterTypes: readonly ParameterType<any>[], generatedExpressions: readonly GeneratedExpression[]): AmbiguousParameterTypeError; | ||
static _parameterTypeNames(parameterTypes: readonly ParameterType<any>[]): string; | ||
static _expressions(generatedExpressions: readonly GeneratedExpression[]): string; | ||
} | ||
@@ -22,0 +22,0 @@ export declare class UndefinedParameterTypeError extends CucumberExpressionError { |
import Argument from './Argument'; | ||
export default interface Expression { | ||
readonly source: string; | ||
match(text: string): ReadonlyArray<Argument<any>>; | ||
match(text: string): readonly Argument<any>[]; | ||
} | ||
//# sourceMappingURL=Expression.d.ts.map |
import ParameterType from './ParameterType'; | ||
export default class GeneratedExpression { | ||
private readonly expressionTemplate; | ||
readonly parameterTypes: ReadonlyArray<ParameterType<any>>; | ||
constructor(expressionTemplate: string, parameterTypes: ReadonlyArray<ParameterType<any>>); | ||
readonly parameterTypes: readonly ParameterType<any>[]; | ||
constructor(expressionTemplate: string, parameterTypes: readonly ParameterType<any>[]); | ||
get source(): string; | ||
@@ -12,4 +12,4 @@ /** | ||
*/ | ||
get parameterNames(): ReadonlyArray<string>; | ||
get parameterNames(): readonly string[]; | ||
} | ||
//# sourceMappingURL=GeneratedExpression.d.ts.map |
@@ -5,6 +5,6 @@ export default class Group { | ||
readonly end: number; | ||
readonly children: ReadonlyArray<Group>; | ||
constructor(value: string | undefined, start: number, end: number, children: ReadonlyArray<Group>); | ||
readonly children: readonly Group[]; | ||
constructor(value: string | undefined, start: number, end: number, children: readonly Group[]); | ||
get values(): string[]; | ||
} | ||
//# sourceMappingURL=Group.d.ts.map |
@@ -10,3 +10,3 @@ export default class ParameterType<T> { | ||
static isValidParameterTypeName(typeName: string): boolean; | ||
regexpStrings: ReadonlyArray<string>; | ||
regexpStrings: readonly string[]; | ||
/** | ||
@@ -20,5 +20,5 @@ * @param name {String} the name of the type | ||
*/ | ||
constructor(name: string, regexps: ReadonlyArray<RegExp> | ReadonlyArray<string> | RegExp | string, type: any, transform: (...match: string[]) => T, useForSnippets: boolean, preferForRegexpMatch: boolean); | ||
constructor(name: string, regexps: readonly RegExp[] | readonly string[] | RegExp | string, type: any, transform: (...match: string[]) => T, useForSnippets: boolean, preferForRegexpMatch: boolean); | ||
transform(thisObj: any, groupValues: string[]): any; | ||
} | ||
//# sourceMappingURL=ParameterType.d.ts.map |
@@ -9,5 +9,5 @@ import Argument from './Argument'; | ||
constructor(regexp: RegExp, parameterTypeRegistry: ParameterTypeRegistry); | ||
match(text: string): ReadonlyArray<Argument<any>>; | ||
match(text: string): readonly Argument<any>[]; | ||
get source(): string; | ||
} | ||
//# sourceMappingURL=RegularExpression.d.ts.map |
@@ -36,8 +36,8 @@ "use strict"; | ||
it('creates a RegularExpression', () => { | ||
assert.equal(expressionFactory.createExpression(/x/).constructor, RegularExpression_1.default); | ||
assert.strictEqual(expressionFactory.createExpression(/x/).constructor, RegularExpression_1.default); | ||
}); | ||
it('creates a CucumberExpression', () => { | ||
assert.equal(expressionFactory.createExpression('x').constructor, CucumberExpression_1.default); | ||
assert.strictEqual(expressionFactory.createExpression('x').constructor, CucumberExpression_1.default); | ||
}); | ||
}); | ||
//# sourceMappingURL=ExpressionFactoryTest.js.map |
{ | ||
"name": "@cucumber/cucumber-expressions", | ||
"version": "12.1.1", | ||
"version": "12.1.2", | ||
"description": "Cucumber Expressions - a simpler alternative to Regular Expressions", | ||
@@ -28,12 +28,12 @@ "main": "dist/src/index.js", | ||
"devDependencies": { | ||
"@types/js-yaml": "^4.0.0", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^14.14.37", | ||
"js-yaml": "^4.0.0", | ||
"mocha": "^8.3.2", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.2.3" | ||
"@types/js-yaml": "4.0.2", | ||
"@types/mocha": "9.0.0", | ||
"@types/node": "16.6.1", | ||
"js-yaml": "4.1.0", | ||
"mocha": "9.0.3", | ||
"ts-node": "10.2.0", | ||
"typescript": "4.3.5" | ||
}, | ||
"dependencies": { | ||
"becke-ch--regex--s0-0-v1--base--pl--lib": "^1.4.0" | ||
"becke-ch--regex--s0-0-v1--base--pl--lib": "1.4.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "directories": { |
@@ -10,4 +10,4 @@ import TreeRegexp from './TreeRegexp' | ||
text: string, | ||
parameterTypes: ReadonlyArray<ParameterType<any>> | ||
): ReadonlyArray<Argument<any>> { | ||
parameterTypes: readonly ParameterType<any>[] | ||
): readonly Argument<any>[] { | ||
const group = treeRegexp.match(text) | ||
@@ -14,0 +14,0 @@ if (!group) { |
@@ -45,3 +45,3 @@ const escapeCharacter = '\\' | ||
readonly type: NodeType | ||
readonly nodes?: ReadonlyArray<Node> | undefined | ||
readonly nodes?: readonly Node[] | undefined | ||
readonly token?: string | undefined | ||
@@ -53,3 +53,3 @@ readonly start: number | ||
type: NodeType, | ||
nodes: ReadonlyArray<Node> = undefined, | ||
nodes: readonly Node[] = undefined, | ||
token: string = undefined, | ||
@@ -56,0 +56,0 @@ start: number, |
@@ -15,3 +15,3 @@ import GeneratedExpression from './GeneratedExpression' | ||
public generateExpressions(): ReadonlyArray<GeneratedExpression> { | ||
public generateExpressions(): readonly GeneratedExpression[] { | ||
const generatedExpressions: GeneratedExpression[] = [] | ||
@@ -18,0 +18,0 @@ this.generatePermutations(generatedExpressions, 0, []) |
@@ -142,3 +142,3 @@ import ParameterTypeRegistry from './ParameterTypeRegistry' | ||
public match(text: string): ReadonlyArray<Argument<any>> { | ||
public match(text: string): readonly Argument<any>[] { | ||
return Argument.build(this.treeRegexp, text, this.parameterTypes) | ||
@@ -145,0 +145,0 @@ } |
@@ -11,3 +11,3 @@ import ParameterTypeMatcher from './ParameterTypeMatcher' | ||
public generateExpressions(text: string): ReadonlyArray<GeneratedExpression> { | ||
public generateExpressions(text: string): readonly GeneratedExpression[] { | ||
const parameterTypeCombinations: Array<Array<ParameterType<any>>> = [] | ||
@@ -14,0 +14,0 @@ const parameterTypeMatchers = this.createParameterTypeMatchers(text) |
@@ -12,3 +12,3 @@ import { Node, NodeType, Token, TokenType } from './Ast' | ||
*/ | ||
function parseText(expression: string, tokens: ReadonlyArray<Token>, current: number) { | ||
function parseText(expression: string, tokens: readonly Token[], current: number) { | ||
const token = tokens[current] | ||
@@ -39,3 +39,3 @@ switch (token.type) { | ||
*/ | ||
function parseName(expression: string, tokens: ReadonlyArray<Token>, current: number) { | ||
function parseName(expression: string, tokens: readonly Token[], current: number) { | ||
const token = tokens[current] | ||
@@ -89,7 +89,3 @@ switch (token.type) { | ||
*/ | ||
function parseAlternativeSeparator( | ||
expression: string, | ||
tokens: ReadonlyArray<Token>, | ||
current: number | ||
) { | ||
function parseAlternativeSeparator(expression: string, tokens: readonly Token[], current: number) { | ||
if (!lookingAt(tokens, current, TokenType.alternation)) { | ||
@@ -105,3 +101,3 @@ return { consumed: 0 } | ||
const alternativeParsers: ReadonlyArray<Parser> = [ | ||
const alternativeParsers: readonly Parser[] = [ | ||
parseAlternativeSeparator, | ||
@@ -178,3 +174,3 @@ parseOptional, | ||
interface Parser { | ||
(expression: string, tokens: ReadonlyArray<Token>, current: number): Result | ||
(expression: string, tokens: readonly Token[], current: number): Result | ||
} | ||
@@ -184,3 +180,3 @@ | ||
readonly consumed: number | ||
readonly ast?: ReadonlyArray<Node> | ||
readonly ast?: readonly Node[] | ||
} | ||
@@ -220,4 +216,4 @@ | ||
expression: string, | ||
parsers: ReadonlyArray<Parser>, | ||
tokens: ReadonlyArray<Token>, | ||
parsers: readonly Parser[], | ||
tokens: readonly Token[], | ||
startAt: number | ||
@@ -238,6 +234,6 @@ ): Result { | ||
expression: string, | ||
parsers: ReadonlyArray<Parser>, | ||
tokens: ReadonlyArray<Token>, | ||
parsers: readonly Parser[], | ||
tokens: readonly Token[], | ||
startAt: number, | ||
endTokens: ReadonlyArray<TokenType> | ||
endTokens: readonly TokenType[] | ||
): Result { | ||
@@ -264,5 +260,5 @@ let current = startAt | ||
function lookingAtAny( | ||
tokens: ReadonlyArray<Token>, | ||
tokens: readonly Token[], | ||
at: number, | ||
tokenTypes: ReadonlyArray<TokenType> | ||
tokenTypes: readonly TokenType[] | ||
): boolean { | ||
@@ -272,3 +268,3 @@ return tokenTypes.some((tokenType) => lookingAt(tokens, at, tokenType)) | ||
function lookingAt(tokens: ReadonlyArray<Token>, at: number, token: TokenType): boolean { | ||
function lookingAt(tokens: readonly Token[], at: number, token: TokenType): boolean { | ||
if (at < 0) { | ||
@@ -288,4 +284,4 @@ // If configured correctly this will never happen | ||
end: number, | ||
alternation: ReadonlyArray<Node> | ||
): ReadonlyArray<Node> { | ||
alternation: readonly Node[] | ||
): readonly Node[] { | ||
const separators: Node[] = [] | ||
@@ -310,5 +306,5 @@ const alternatives: Node[][] = [] | ||
end: number, | ||
separators: ReadonlyArray<Node>, | ||
alternatives: ReadonlyArray<ReadonlyArray<Node>> | ||
): ReadonlyArray<Node> { | ||
separators: readonly Node[], | ||
alternatives: readonly ReadonlyArray<Node>[] | ||
): readonly Node[] { | ||
const nodes: Node[] = [] | ||
@@ -315,0 +311,0 @@ |
@@ -5,3 +5,3 @@ import { Token, TokenType } from './Ast' | ||
export default class CucumberExpressionTokenizer { | ||
tokenize(expression: string): ReadonlyArray<Token> { | ||
tokenize(expression: string): readonly Token[] { | ||
const codePoints = Array.from(expression) | ||
@@ -8,0 +8,0 @@ const tokens: Array<Token> = [] |
@@ -186,4 +186,4 @@ import ParameterType from './ParameterType' | ||
keyValue: string, | ||
parameterTypes: ReadonlyArray<ParameterType<any>>, | ||
generatedExpressions: ReadonlyArray<GeneratedExpression> | ||
parameterTypes: readonly ParameterType<any>[], | ||
generatedExpressions: readonly GeneratedExpression[] | ||
) { | ||
@@ -198,4 +198,4 @@ return new this( | ||
expressionRegexp: RegExp, | ||
parameterTypes: ReadonlyArray<ParameterType<any>>, | ||
generatedExpressions: ReadonlyArray<GeneratedExpression> | ||
parameterTypes: readonly ParameterType<any>[], | ||
generatedExpressions: readonly GeneratedExpression[] | ||
) { | ||
@@ -217,7 +217,7 @@ return new this( | ||
public static _parameterTypeNames(parameterTypes: ReadonlyArray<ParameterType<any>>) { | ||
public static _parameterTypeNames(parameterTypes: readonly ParameterType<any>[]) { | ||
return parameterTypes.map((p) => `{${p.name}}`).join('\n ') | ||
} | ||
public static _expressions(generatedExpressions: ReadonlyArray<GeneratedExpression>) { | ||
public static _expressions(generatedExpressions: readonly GeneratedExpression[]) { | ||
return generatedExpressions.map((e) => e.source).join('\n ') | ||
@@ -224,0 +224,0 @@ } |
@@ -5,3 +5,3 @@ import Argument from './Argument' | ||
readonly source: string | ||
match(text: string): ReadonlyArray<Argument<any>> | ||
match(text: string): readonly Argument<any>[] | ||
} |
@@ -7,3 +7,3 @@ import util from 'util' | ||
private readonly expressionTemplate: string, | ||
public readonly parameterTypes: ReadonlyArray<ParameterType<any>> | ||
public readonly parameterTypes: readonly ParameterType<any>[] | ||
) {} | ||
@@ -20,3 +20,3 @@ | ||
*/ | ||
get parameterNames(): ReadonlyArray<string> { | ||
get parameterNames(): readonly string[] { | ||
const usageByTypeName: { [key: string]: number } = {} | ||
@@ -23,0 +23,0 @@ return this.parameterTypes.map((t) => getParameterName(t.name, usageByTypeName)) |
@@ -6,3 +6,3 @@ export default class Group { | ||
public readonly end: number, | ||
public readonly children: ReadonlyArray<Group> | ||
public readonly children: readonly Group[] | ||
) {} | ||
@@ -9,0 +9,0 @@ |
@@ -32,3 +32,3 @@ import CucumberExpressionError from './CucumberExpressionError' | ||
public regexpStrings: ReadonlyArray<string> | ||
public regexpStrings: readonly string[] | ||
@@ -45,3 +45,3 @@ /** | ||
public readonly name: string, | ||
regexps: ReadonlyArray<RegExp> | ReadonlyArray<string> | RegExp | string, | ||
regexps: readonly RegExp[] | readonly string[] | RegExp | string, | ||
private readonly type: any, | ||
@@ -53,3 +53,3 @@ transform: (...match: string[]) => T, | ||
if (transform === undefined) { | ||
transform = (s) => (s as unknown) as T | ||
transform = (s) => s as unknown as T | ||
} | ||
@@ -56,0 +56,0 @@ if (useForSnippets === undefined) { |
@@ -17,3 +17,3 @@ import Argument from './Argument' | ||
public match(text: string): ReadonlyArray<Argument<any>> { | ||
public match(text: string): readonly Argument<any>[] { | ||
const parameterTypes = this.treeRegexp.groupBuilder.children.map((groupBuilder) => { | ||
@@ -20,0 +20,0 @@ const parameterTypeRegexp = groupBuilder.source |
@@ -14,8 +14,8 @@ import * as assert from 'assert' | ||
it('creates a RegularExpression', () => { | ||
assert.equal(expressionFactory.createExpression(/x/).constructor, RegularExpression) | ||
assert.strictEqual(expressionFactory.createExpression(/x/).constructor, RegularExpression) | ||
}) | ||
it('creates a CucumberExpression', () => { | ||
assert.equal(expressionFactory.createExpression('x').constructor, CucumberExpression) | ||
assert.strictEqual(expressionFactory.createExpression('x').constructor, CucumberExpression) | ||
}) | ||
}) |
@@ -63,3 +63,4 @@ import assert from 'assert' | ||
it('matches capture group nested in optional one', () => { | ||
const regexp = /^a (pre-commercial transaction |pre buyer fee model )?purchase(?: for \$(\d+))?$/ | ||
const regexp = | ||
/^a (pre-commercial transaction |pre buyer fee model )?purchase(?: for \$(\d+))?$/ | ||
assert.deepStrictEqual(match(regexp, 'a purchase'), [null, null]) | ||
@@ -66,0 +67,0 @@ assert.deepStrictEqual(match(regexp, 'a purchase for $33'), [null, 33]) |
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 not supported yet
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
381990
5110