From b99c98ca2e245687a43409a37eb34891e5267eb6 Mon Sep 17 00:00:00 2001 From: Charles Loder Date: Fri, 29 Dec 2023 20:57:10 -0500 Subject: [PATCH 1/2] Add tests for isInConstruct --- test/word.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/word.test.ts b/test/word.test.ts index 3193b7c..9dca87e 100644 --- a/test/word.test.ts +++ b/test/word.test.ts @@ -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); + }); +}); From 17f717e82a2e3f8bd3a3b0ea994047f4320c2552 Mon Sep 17 00:00:00 2001 From: Charles Loder Date: Fri, 29 Dec 2023 20:57:35 -0500 Subject: [PATCH 2/2] Add logic for isInConstruct --- src/word.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/word.ts b/src/word.ts index fe61679..13099a1 100644 --- a/src/word.ts +++ b/src/word.ts @@ -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"); + } }