# shared/predicates/text.predicate.ts

> 13 lines of code and 6 definitions.

Tree: Governance tree
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/governance#file-governance-shared-predicates-text-predicate-ts
Source text: https://banes-lab.com/source/governance/shared/predicates/text.predicate.ts.txt

Listed in [shared/predicates](https://banes-lab.com/api/source/governance/shared/predicates.md), after [shared/predicates/location.predicate.ts](https://banes-lab.com/source/governance/shared/predicates/location.predicate.ts.md).

## Definitions

- `isTextFile` (lexical_declaration, line 6, exported)
- `PROBE_BYTES` (lexical_declaration, line 3)
- `NUL` (lexical_declaration, line 4)
- `probe` (lexical_declaration, line 7, exported)
- `handle` (lexical_declaration, line 8, exported)
- `read` (lexical_declaration, line 10, exported)

## Used by

- [shared/analyzers/taxonomy.coverage.analyzer.ts](https://banes-lab.com/source/governance/shared/analyzers/taxonomy.coverage.analyzer.ts.md)

## Source

```typescript
import { closeSync, openSync, readSync } from "node:fs";

const PROBE_BYTES = 8000;
const NUL = 0;

export const isTextFile = function isTextFile(absPath: string): boolean {
    const probe = Buffer.alloc(PROBE_BYTES);
    const handle = openSync(absPath, "r");
    try {
        const read = readSync(handle, probe, 0, PROBE_BYTES, 0);
        return !probe.subarray(0, read).includes(NUL);
    } finally {
        closeSync(handle);
    }
};
```
