From 07707195b1244852863c9a22603e4fa86ce96362 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Tue, 30 Aug 2022 14:33:51 +0400 Subject: [PATCH] more exposed --- package.json | 2 +- src/lib/is-pashto.test.ts | 6 ++++++ src/lib/is-pashto.ts | 9 +++++++++ src/lib/phrase-building/compile.ts | 4 ++-- src/library.ts | 12 +++++++++--- 5 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 src/lib/is-pashto.test.ts create mode 100644 src/lib/is-pashto.ts diff --git a/package.json b/package.json index f6763c9..7fe0cd5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "3.8.3", + "version": "3.8.4", "author": "lingdocs.com", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "homepage": "https://verbs.lingdocs.com", diff --git a/src/lib/is-pashto.test.ts b/src/lib/is-pashto.test.ts new file mode 100644 index 0000000..0ca0b4a --- /dev/null +++ b/src/lib/is-pashto.test.ts @@ -0,0 +1,6 @@ +import { isPashtoScript } from "./is-pashto"; + +test("isPashtoScript works", () => { + expect(isPashtoScript("کور")).toBe(true); + expect(isPashtoScript("kor")).toBe(false); +}); diff --git a/src/lib/is-pashto.ts b/src/lib/is-pashto.ts new file mode 100644 index 0000000..e01a489 --- /dev/null +++ b/src/lib/is-pashto.ts @@ -0,0 +1,9 @@ +/** + * Determines if a string is written in Pashto script; + */ + +const pashtoLetters = /[\u0600-\u06FF]/; + +export function isPashtoScript(s: string): boolean { + return pashtoLetters.test(s); +} \ No newline at end of file diff --git a/src/lib/phrase-building/compile.ts b/src/lib/phrase-building/compile.ts index 775925d..438461d 100644 --- a/src/lib/phrase-building/compile.ts +++ b/src/lib/phrase-building/compile.ts @@ -26,13 +26,13 @@ import { specifyEquativeLength, } from "./blocks-utils"; -const blank: T.PsString = { +export const blank: T.PsString = { p: "_____", f: "_____", }; type BlankoutOptions = { equative?: boolean, ba?: boolean, kidsSection?: boolean, verb?: boolean }; -const kidsBlank: T.PsString = { p: "___", f: "___" }; +export const kidsBlank: T.PsString = { p: "___", f: "___" }; // function compilePs({ blocks, kids, verb: { head, rest }, VP }: CompilePsInput): T.SingleOrLengthOpts { diff --git a/src/library.ts b/src/library.ts index 907c38c..d0d30ff 100644 --- a/src/library.ts +++ b/src/library.ts @@ -39,6 +39,9 @@ import Block, { NPBlock, APBlock } from "./components/blocks/Block"; import { roleIcon } from "./components/vp-explorer/VPExplorerExplanationModal"; import CompiledPTextDisplay from "./components/CompiledPTextDisplay"; import RenderedBlocksDisplay from "./components/RenderedBlocksDisplay"; +import { + isPashtoScript, +} from "./lib/is-pashto"; import { makePsString, removeFVarients, @@ -120,9 +123,6 @@ import { isSecondPerson, isThirdPerson, } from "./lib/misc-helpers"; -import { - flattenLengths, -} from "./lib/phrase-building/compile"; import { simplifyPhonetics, } from "./lib/simplify-phonetics"; @@ -153,6 +153,9 @@ import { import { compileEP, compileVP, + flattenLengths, + blank, + kidsBlank, } from "./lib/phrase-building/compile"; import { renderAPSelection, @@ -253,6 +256,9 @@ export { vpsReducer, makeVPSelectionState, blockUtils, + blank, + kidsBlank, + isPashtoScript, // protobuf helpers readDictionary, writeDictionary,