core/predicates/token.predicate.ts

core/predicates/token.predicate.ts is a file in Secrets. 13 lines of code and 1 definition.

import { TOKEN_SHAPES } from "#configuration/constants/detector.constants";
import { defineDetector } from "#core/registries/detector.registry";
import { isInAlphabet } from "#core/predicates/character.predicate";

defineDetector({
    detects: (value) =>
        TOKEN_SHAPES.some((shape) =>
            shape.prefixes.some((prefix) => {
                const rest = value.slice(prefix.length);
                return value.startsWith(prefix) && rest.length >= shape.minRest && isInAlphabet(rest, shape.alphabet);
            }),
        ),
    kind: "token",
});