Page MenuHomeSealhub

hyphenation.ts
No OneTemporary

hyphenation.ts

import hyphenopoly from "hyphenopoly";
import { resolve } from "node:path";
import { readFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";
async function make_hyphenator(lang: string) {
return hyphenopoly.config({
require: [lang],
sync: false,
loader: async (file: string, module_path: URL) => {
return readFile(
resolve(fileURLToPath(module_path), `../patterns/${file}`)
);
},
});
}
const hyphenators: Record<
string,
Promise<(text: string) => string> | undefined
> = {};
export function get_hyphenator(
lang: string
): Promise<(text: string) => string> {
const hyphenator = hyphenators[lang] || make_hyphenator(lang);
if (!hyphenators[lang]) {
hyphenators[lang] = hyphenator;
}
return hyphenator;
}

File Metadata

Mime Type
text/x-java
Expires
Wed, May 7, 19:43 (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
625519
Default Alt Text
hyphenation.ts (757 B)

Event Timeline