# tools/core/predicates/comment.predicate.ts

> 34 lines of code and 8 definitions.

Tree: Coordination tree
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tools-core-predicates-comment-predicate-ts
Source text: https://banes-lab.com/assets/sources/source.ae450c0d0e120e539cd3e8b3d961f2741448f7bba38f497b8755395b0cc16bfe.generated.txt

## Definitions

- `isAttribution` (lexical_declaration, line 25, exported)
- `endOfQuoted` (lexical_declaration, line 29, exported)
- `CommentSpan` (interface_declaration, line 1, exported)
- `ATTRIBUTION_MARKERS` (lexical_declaration, line 7)
- `ESCAPE` (lexical_declaration, line 19)
- `at` (lexical_declaration, line 21, exported)
- `cursor` (lexical_declaration, line 30, exported)
- `char` (lexical_declaration, line 32, exported)

## Used by

- [tools/core/normalizers/source.normalizer.ts](https://banes-lab.com/source/coordination/tools/core/normalizers/source.normalizer.ts.md)
- [tools/core/steps/source.step.ts](https://banes-lab.com/source/coordination/tools/core/steps/source.step.ts.md)
- [tools/rules/literal.rule.ts](https://banes-lab.com/source/coordination/tools/rules/literal.rule.ts.md)

## Source

```typescript
export interface CommentSpan {
    readonly start: number;
    readonly end: number;
    readonly text: string;
}

const ATTRIBUTION_MARKERS = [
    "SPDX-License-Identifier",
    "Copyright",
    "copyright",
    "CC BY-SA",
    "Bane's Lab",
    "License:",
    "MIT License",
    "BSD License",
    "All rights reserved",
] as const;

const ESCAPE = "\\";

export const at = function at(text: string, index: number): string {
    return text[index] ?? "";
};

export const isAttribution = function isAttribution(text: string): boolean {
    return ATTRIBUTION_MARKERS.some((marker) => text.includes(marker));
};

export const endOfQuoted = function endOfQuoted(source: string, start: number, quote: string): number {
    let cursor = start;
    while (cursor < source.length) {
        const char = at(source, cursor);
        if (char === quote) {
            return cursor + 1;
        }
        cursor += char === ESCAPE ? 2 : 1;
    }
    return cursor;
};
```
