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

Code cleanup #179

Merged
merged 8 commits into from
Sep 11, 2024
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
26 changes: 21 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# This is a basic workflow to help you get started with Actions

name: Build docs on version update

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
# Triggers the workflow on push or pull request events but only for the main branch
push:
tags:
- "*"
Expand All @@ -15,7 +13,6 @@ on:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-and-deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand All @@ -24,11 +21,30 @@ jobs:
uses: actions/checkout@v2

- name: Install and Build
# use force because typedoc doesn't support current version of TS, but it still build
run: |
npm install
npm run docs

- name: Check for changes
id: git-check
run: |
git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT

- name: Commit changes
if: steps.git-check.outputs.changes == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
git commit -m "Auto-update documentation"

- name: Push changes
if: steps.git-check.outputs.changes == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main

- name: Deploy
uses: JamesIves/[email protected]
with:
Expand Down
79 changes: 39 additions & 40 deletions src/char.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,73 +10,72 @@ export class Char {
#text: string;
#cluster: Cluster | null = null;
#sequencePosition: number;
#isCharKeyOfCharToNameMap = isHebrewCharacter;

constructor(char: string) {
this.#text = char;
this.#sequencePosition = this.findPos();
this.#sequencePosition = this.#findPos();
}

private findPos(): number {
#findPos() {
const char = this.text;
if (Char.consonants.test(char)) {
if (Char.#consonants.test(char)) {
return 0;
}
if (Char.ligatures.test(char)) {
if (Char.#ligatures.test(char)) {
return 1;
}
if (Char.dagesh.test(char)) {
if (Char.#dagesh.test(char)) {
return 2;
}
if (Char.rafe.test(char)) {
if (Char.#rafe.test(char)) {
return 2;
}
if (Char.vowels.test(char)) {
if (Char.#vowels.test(char)) {
return 3;
}
if (Char.sheva.test(char)) {
if (Char.#sheva.test(char)) {
return 3;
}
if (Char.taamim.test(char)) {
if (Char.#taamim.test(char)) {
return 4;
}
if (Char.meteg.test(char)) {
if (Char.#meteg.test(char)) {
return 4;
}
// i.e. any non-hebrew char
return 10;
}

private isCharKeyOfCharToNameMap = isHebrewCharacter;

private static get consonants() {
static get #consonants() {
return consonants;
}

private static get dagesh() {
static get #dagesh() {
return dagesh;
}

private static get ligatures() {
static get #ligatures() {
return ligatures;
}

private static get meteg() {
static get #meteg() {
return meteg;
}

private static get rafe() {
static get #rafe() {
return rafe;
}

private static get sheva() {
static get #sheva() {
return sheva;
}

private static get taamim() {
static get #taamim() {
return taamim;
}

private static get vowels() {
static get #vowels() {
return vowels;
}

Expand All @@ -93,7 +92,7 @@ export class Char {
* // "דָּ"
* ```
*/
get cluster(): Cluster | null {
get cluster() {
return this.#cluster;
}

Expand All @@ -106,7 +105,7 @@ export class Char {
*
* @param name a character name
*/
isCharacterName(name: keyof NameToCharMap): boolean {
isCharacterName(name: keyof NameToCharMap) {
if (!nameToCharMap[name]) {
throw new Error(`${name} is not a valid value`);
}
Expand All @@ -126,8 +125,8 @@ export class Char {
* // true
* ```
*/
get isConsonant(): boolean {
return Char.consonants.test(this.#text);
get isConsonant() {
return Char.#consonants.test(this.#text);
}

/**
Expand All @@ -140,8 +139,8 @@ export class Char {
* // true
* ```
*/
get isLigature(): boolean {
return Char.ligatures.test(this.#text);
get isLigature() {
return Char.#ligatures.test(this.#text);
}

/**
Expand All @@ -154,8 +153,8 @@ export class Char {
* // true
* ```
*/
get isDagesh(): boolean {
return Char.dagesh.test(this.#text);
get isDagesh() {
return Char.#dagesh.test(this.#text);
}

/**
Expand All @@ -168,8 +167,8 @@ export class Char {
* // true
* ```
*/
get isRafe(): boolean {
return Char.rafe.test(this.#text);
get isRafe() {
return Char.#rafe.test(this.#text);
}

/**
Expand All @@ -182,8 +181,8 @@ export class Char {
* // true
* ```
*/
get isSheva(): boolean {
return Char.sheva.test(this.#text);
get isSheva() {
return Char.#sheva.test(this.#text);
}

/**
Expand All @@ -196,8 +195,8 @@ export class Char {
* // true
* ```
*/
get isVowel(): boolean {
return Char.vowels.test(this.#text);
get isVowel() {
return Char.#vowels.test(this.#text);
}

/**
Expand All @@ -210,8 +209,8 @@ export class Char {
* // true
* ```
*/
get isTaamim(): boolean {
return Char.taamim.test(this.#text);
get isTaamim() {
return Char.#taamim.test(this.#text);
}

/**
Expand All @@ -224,7 +223,7 @@ export class Char {
* // true
* ```
*/
get isNotHebrew(): boolean {
get isNotHebrew() {
return this.sequencePosition === 10;
}

Expand All @@ -240,7 +239,7 @@ export class Char {
*/
get characterName(): CharToNameMap[keyof CharToNameMap] | null {
const text = this.#text;
if (this.isCharKeyOfCharToNameMap(text)) {
if (this.#isCharKeyOfCharToNameMap(text)) {
return charToNameMap[text];
}
return null;
Expand All @@ -265,7 +264,7 @@ export class Char {
* // 3
* ```
*/
get sequencePosition(): number {
get sequencePosition() {
return this.#sequencePosition;
}

Expand All @@ -281,7 +280,7 @@ export class Char {
* // "א"
* ```
*/
get text(): string {
get text() {
return this.#text;
}
}
Loading
Loading