charlesLoder / havarotjs

A Typescript package for getting syllabic data about Hebrew text with niqqud.
https://www.npmjs.com/package/havarotjs
MIT License
12 stars 6 forks source link

Generics #101

Closed charlesLoder closed 1 year ago

charlesLoder commented 1 year ago

Closes #98

While calling next or prev won't get type-safety, now you can call value to get the object of next and prev.

Example:

const str = `כּוֹרֶשׁ כּ֫וֹרֶשׁ`;
const text = new Text(str);
const syllable = text.syllables[0]; // is a Syllable
const next = syllable.next; // no Syllable types, only Node types (i.e. prev, next, siblings)
const nextSyl = next?.value // is a Syllable
console.log(nextSyl?.text); // "רֶשׁ"