Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is in construct #149

Merged
merged 2 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/word.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,15 @@ export class Word {
get isNotHebrew(): boolean {
return !this.clusters.map((c) => c.isNotHebrew).includes(false);
}

/**
* Returns `true` if the Word is in a construct state
*
* @description
* The construct state is indicated by the presence of a maqqef (U+05BE) character
*/
get isInConstruct(): boolean {
// if word has a maqqef, it is in construct
return this.text.includes("\u05BE");
}
}
11 changes: 11 additions & 0 deletions test/word.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,14 @@ describe.each`
});
});
});

describe.each`
description | heb | isInConstructArray
${"with maqqef"} | ${"בֶּן־אָדָ֕ם"} | ${[true, false]}
${"now maqqef"} | ${"בֶּן אָדָ֕ם"} | ${[false, false]}
`("isInConstruct:", ({ description, heb, isInConstructArray }) => {
const text = new Text(heb);
test(`${description}`, () => {
expect(text.words.map((word) => word.isInConstruct)).toEqual(isInConstructArray);
});
});