is_text_file() — svelte Function Reference
Architecture documentation for the is_text_file() function in hash.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 8a30439d_fe64_ea54_bcb4_9d9c4272cbe0["is_text_file()"] 701d9da6_675f_b6d1_ad30_b067ef212b63["hash.js"] 8a30439d_fe64_ea54_bcb4_9d9c4272cbe0 -->|defined in| 701d9da6_675f_b6d1_ad30_b067ef212b63 style 8a30439d_fe64_ea54_bcb4_9d9c4272cbe0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
playgrounds/sandbox/scripts/hash.js lines 9–26
function is_text_file(filepath) {
const buffer = fs.readFileSync(filepath);
// Check for null bytes which indicate binary files
for (let i = 0; i < buffer.length; i++) {
if (buffer[i] === 0) {
return false;
}
}
// Validate UTF-8 encoding
try {
const text = buffer.toString('utf-8');
// Verify round-trip encoding to ensure valid UTF-8
const encoded = Buffer.from(text, 'utf-8');
return buffer.equals(encoded);
} catch {
return false;
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does is_text_file() do?
is_text_file() is a function in the svelte codebase, defined in playgrounds/sandbox/scripts/hash.js.
Where is is_text_file() defined?
is_text_file() is defined in playgrounds/sandbox/scripts/hash.js at line 9.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free