Skip to content

Commit

Permalink
Merge pull request #149 from charlesLoder/is-in-construct
Browse files Browse the repository at this point in the history
Is in construct
  • Loading branch information
charlesLoder authored Dec 30, 2023
2 parents 26a3ca8 + 17f717e commit e556d06
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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);
});
});

0 comments on commit e556d06

Please sign in to comment.