mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-25 09:50:19 +00:00
22 lines
493 B
TypeScript
22 lines
493 B
TypeScript
import fs from 'node:fs/promises'
|
|
|
|
export async function readFile (doc: string): Promise<string> {
|
|
const buffer = await fs.readFile(doc)
|
|
return buffer.toString()
|
|
}
|
|
|
|
function peelStr (s: string): string {
|
|
return s
|
|
.replace(/^[\W_0-9]*/, '')
|
|
.replace(/[\W_0-9]*$/, '')
|
|
.toLowerCase()
|
|
}
|
|
|
|
export function compareStrExact (a: string, b: string): boolean {
|
|
return peelStr(a) === peelStr(b)
|
|
}
|
|
|
|
export function clean (s: string): string {
|
|
return s.replaceAll('\n', ' ').trim()
|
|
}
|