Skip to content

Commit 3246bc9

Browse files
committed
Explicit return types
1 parent 5de5056 commit 3246bc9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ export function pathToRegexp(
487487
for (const input of pathsToArray(path, [])) {
488488
const data = typeof input === "object" ? input : parse(input, options);
489489
for (const tokens of flatten(data.tokens, 0, [])) {
490-
sources.push(toRegExp(tokens, delimiter, keys, data.originalPath));
490+
sources.push(toRegExpSource(tokens, delimiter, keys, data.originalPath));
491491
}
492492
}
493493

@@ -544,12 +544,12 @@ function* flatten(
544544
/**
545545
* Transform a flat sequence of tokens into a regular expression.
546546
*/
547-
function toRegExp(
547+
function toRegExpSource(
548548
tokens: FlatToken[],
549549
delimiter: string,
550550
keys: Keys,
551551
originalPath: string | undefined,
552-
) {
552+
): string {
553553
let result = "";
554554
let backtrack = "";
555555
let isSafeSegmentParam = true;
@@ -588,7 +588,7 @@ function toRegExp(
588588
/**
589589
* Block backtracking on previous text and ignore delimiter string.
590590
*/
591-
function negate(delimiter: string, backtrack: string) {
591+
function negate(delimiter: string, backtrack: string): string {
592592
if (backtrack.length < 2) {
593593
if (delimiter.length < 2) return `[^${escape(delimiter + backtrack)}]`;
594594
return `(?:(?!${escape(delimiter)})[^${escape(backtrack)}])`;
@@ -643,22 +643,22 @@ function stringifyTokens(tokens: Token[]): string {
643643
/**
644644
* Stringify token data into a path string.
645645
*/
646-
export function stringify(data: TokenData) {
646+
export function stringify(data: TokenData): string {
647647
return stringifyTokens(data.tokens);
648648
}
649649

650650
/**
651651
* Validate the parameter name contains valid ID characters.
652652
*/
653-
function isNameSafe(name: string) {
653+
function isNameSafe(name: string): boolean {
654654
const [first, ...rest] = name;
655655
return ID_START.test(first) && rest.every((char) => ID_CONTINUE.test(char));
656656
}
657657

658658
/**
659659
* Validate the next token does not interfere with the current param name.
660660
*/
661-
function isNextNameSafe(token: Token | undefined) {
661+
function isNextNameSafe(token: Token | undefined): boolean {
662662
if (token && token.type === "text") return !ID_CONTINUE.test(token.value[0]);
663663
return true;
664664
}

0 commit comments

Comments
 (0)