Skip to content

Commit 98d1d4b

Browse files
committed
Limits transformations
1 parent 8660286 commit 98d1d4b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/utils/transform.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
const transform = (replacement: string) => (transformations: Array<string>) => (
2-
...config: Array<string>
3-
) => {
1+
const transform = (replacement: string) => (
2+
transformations: Array<
3+
"toUpperCase" | "toLowerCase" | "trim" | "trimLeft" | "trimRight"
4+
>,
5+
) => (...config: Array<string>) => {
46
const [offset, string] = config.slice(-2);
57

68
const matches = config.slice(0, -2);
79

810
const transformedMatches = transformations.map((transformation, i) =>
9-
matches[i][transformation]()
11+
matches[i][transformation](),
1012
);
1113

1214
const allMatches = transformedMatches.concat(
13-
matches.slice(transformedMatches.length)
15+
matches.slice(transformedMatches.length),
1416
);
1517

1618
return replacement

0 commit comments

Comments
 (0)