MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / tokenVariants

Function tokenVariants

apps/cli/src/tooling.ts:348–364  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

346 .filter((token) => token.length > 0);
347
348const tokenVariants = (input: string): ReadonlyArray<string> => {
349 const token = input.toLowerCase();
350 const variants = new Set<string>([token]);
351
352 if (token.endsWith("ies") && token.length > 3) {
353 variants.add(`${token.slice(0, -3)}y`);
354 } else if (token.endsWith("s") && token.length > 1) {
355 variants.add(token.slice(0, -1));
356 } else {
357 variants.add(`${token}s`);
358 if (token.endsWith("y") && token.length > 1) {
359 variants.add(`${token.slice(0, -1)}ies`);
360 }
361 }
362
363 return [...variants];
364};
365
366const segmentMatchesToken = (segment: string, queryToken: string): boolean => {
367 const normalizedSegment = segment.toLowerCase();

Callers 1

segmentMatchesTokenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected