# core/predicates/code-point.predicate.ts

> 26 lines of code and 21 definitions.

Tree: GovLab Quality
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/quality#file-quality-core-predicates-code-point-predicate-ts
Source text: https://banes-lab.com/source/quality/core/predicates/code-point.predicate.ts.txt

Listed in [core/predicates](https://banes-lab.com/api/source/quality/core/predicates.md), before [core/predicates/concept.predicate.ts](https://banes-lab.com/source/quality/core/predicates/concept.predicate.ts.md).

## Definitions

- `inSet` (lexical_declaration, line 18)
- `isAsciiUpper` (lexical_declaration, line 22, exported)
- `isAsciiDigit` (lexical_declaration, line 28, exported)
- `isDot` (lexical_declaration, line 32, exported)
- `isCssNameChar` (lexical_declaration, line 38, exported)
- `isAsciiLower` (lexical_declaration, line 24, exported)
- `isAsciiAlpha` (lexical_declaration, line 26, exported)
- `isSnakeTail` (lexical_declaration, line 36, exported)
- `isKebabChar` (lexical_declaration, line 30, exported)
- `isIdentChar` (lexical_declaration, line 34, exported)
- `codesOf` (lexical_declaration, line 3)
- `UPPER_CODES` (lexical_declaration, line 7)
- `LOWER_CODES` (lexical_declaration, line 8)
- `DIGIT_CODES` (lexical_declaration, line 9)
- `ALPHA_CODES` (lexical_declaration, line 10)
- `ALPHANUMERIC_CODES` (lexical_declaration, line 11)
- `IDENT_CODES` (lexical_declaration, line 12)
- `SNAKE_TAIL_CODES` (lexical_declaration, line 13)
- `CSS_NAME_CODES` (lexical_declaration, line 14)
- `KEBAB_CODES` (lexical_declaration, line 15)
- `DOT_CODES` (lexical_declaration, line 16)

## Contained in

- [core/predicates](https://banes-lab.com/anatomy/quality/folder-quality-core-predicates.md)

## Used by

- [core/converters/css.converter.ts](https://banes-lab.com/source/quality/core/converters/css.converter.ts.md)
- [core/parsers/css.parser.ts](https://banes-lab.com/source/quality/core/parsers/css.parser.ts.md)
- [core/predicates/constants.predicate.ts](https://banes-lab.com/source/quality/core/predicates/constants.predicate.ts.md)
- [core/stylelint/consistent-naming.stylelint.rule.ts](https://banes-lab.com/source/quality/core/stylelint/consistent-naming.stylelint.rule.ts.md)
- [core/stylelint/custom-property-order.stylelint.rule.ts](https://banes-lab.com/source/quality/core/stylelint/custom-property-order.stylelint.rule.ts.md)
- [core/validators/filename.validator.ts](https://banes-lab.com/source/quality/core/validators/filename.validator.ts.md)

## Linked from

- [core/converters](https://banes-lab.com/anatomy/quality/folder-quality-core-converters.md)
- [core/parsers](https://banes-lab.com/anatomy/quality/folder-quality-core-parsers.md)
- [core/predicates](https://banes-lab.com/anatomy/quality/folder-quality-core-predicates.md)
- [core/stylelint](https://banes-lab.com/anatomy/quality/folder-quality-core-stylelint.md)
- [core/validators](https://banes-lab.com/anatomy/quality/folder-quality-core-validators.md)

## Source

```typescript
import { DIGITS, LOWER_ALPHA, UPPER_ALPHA } from "@govlab/constants";

const codesOf = function codesOf(chars: readonly string[]): Set<number> {
    return new Set(chars.map((ch) => ch.codePointAt(0) ?? -1));
};

const UPPER_CODES = codesOf(UPPER_ALPHA);
const LOWER_CODES = codesOf(LOWER_ALPHA);
const DIGIT_CODES = codesOf(DIGITS);
const ALPHA_CODES = new Set([...UPPER_CODES, ...LOWER_CODES]);
const ALPHANUMERIC_CODES = new Set([...ALPHA_CODES, ...DIGIT_CODES]);
const IDENT_CODES = new Set([...ALPHANUMERIC_CODES, ...codesOf(["_", "$"])]);
const SNAKE_TAIL_CODES = new Set([...DIGIT_CODES, ...codesOf(["_"])]);
const CSS_NAME_CODES = new Set([...ALPHANUMERIC_CODES, ...codesOf(["-", "_"])]);
const KEBAB_CODES = new Set([...LOWER_CODES, ...DIGIT_CODES, ...codesOf(["-"])]);
const DOT_CODES = codesOf(["."]);

const inSet = function inSet(codes: ReadonlySet<number>, code: number | undefined): boolean {
    return typeof code === "number" && codes.has(code);
};

export const isAsciiUpper = (code: number | undefined): boolean => inSet(UPPER_CODES, code);

export const isAsciiLower = (code: number | undefined): boolean => inSet(LOWER_CODES, code);

export const isAsciiAlpha = (code: number | undefined): boolean => inSet(ALPHA_CODES, code);

export const isAsciiDigit = (code?: number): boolean => inSet(DIGIT_CODES, code);

export const isKebabChar = (code: number | undefined): boolean => inSet(KEBAB_CODES, code);

export const isDot = (code: number | undefined): boolean => inSet(DOT_CODES, code);

export const isIdentChar = (code: number | undefined): boolean => inSet(IDENT_CODES, code);

export const isSnakeTail = (code: number | undefined): boolean => inSet(SNAKE_TAIL_CODES, code);

export const isCssNameChar = (code: number | undefined): boolean => inSet(CSS_NAME_CODES, code);
```
