# core/predicates/closure.predicate.ts

> 20 lines of code and 6 definitions.

Tree: Project Scripts
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/scripts#file-scripts-core-predicates-closure-predicate-ts
Source text: https://banes-lab.com/source/scripts/core/predicates/closure.predicate.ts.txt

Listed in [core/predicates](https://banes-lab.com/api/source/scripts/core/predicates.md).

## Definitions

- `isRegisterCall` (lexical_declaration, line 14, exported)
- `opensVerb` (lexical_declaration, line 6)
- `isConsumerCall` (lexical_declaration, line 18, exported)
- `UPPER_FIRST` (lexical_declaration, line 3)
- `UPPER_LAST` (lexical_declaration, line 4)
- `code` (lexical_declaration, line 10)

## Contained in

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

## Used by

- [core/converters/closure.converter.ts](https://banes-lab.com/source/scripts/core/converters/closure.converter.ts.md)

## Linked from

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

## Source

```typescript
import { CONSUMER_PREFIXES, DOM_CONSUMER_BUILTINS, REGISTER_PREFIX } from "#configuration/constants/closure.constants";

const UPPER_FIRST = 65;
const UPPER_LAST = 90;

const opensVerb = function opensVerb(name: string, prefix: string): boolean {
    if (!name.startsWith(prefix) || name.length <= prefix.length) {
        return false;
    }
    const code = name.codePointAt(prefix.length) ?? 0;
    return code >= UPPER_FIRST && code <= UPPER_LAST;
};

export const isRegisterCall = function isRegisterCall(name: string): boolean {
    return opensVerb(name, REGISTER_PREFIX);
};

export const isConsumerCall = function isConsumerCall(name: string): boolean {
    return (
        !isRegisterCall(name) &&
        !DOM_CONSUMER_BUILTINS.has(name) &&
        CONSUMER_PREFIXES.some((prefix) => opensVerb(name, prefix))
    );
};
```
