diff --git a/package.json b/package.json index 272cafe..b188b4e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "1.2.2", + "version": "1.2.3", "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/p-text-helpers.test.ts b/src/lib/p-text-helpers.test.ts index a4c7236..0f7ff71 100644 --- a/src/lib/p-text-helpers.test.ts +++ b/src/lib/p-text-helpers.test.ts @@ -1152,6 +1152,8 @@ test("endsWith", () => { .toBe(false); expect(endsWith({ p: ["د", "ت"] }, { p: "چت", f: "chat" })) .toBe(true); + expect(endsWith([{ p: "ای", f: "aay" }, { p: ["د", "ت"] }], { p: "چت", f: "chat" })) + .toBe(true); expect(endsWith({ p: ["ډ", "د"] }, { p: "چت", f: "chat" })) .toBe(false); // ability to curry diff --git a/src/lib/p-text-helpers.ts b/src/lib/p-text-helpers.ts index b23c460..0460acc 100644 --- a/src/lib/p-text-helpers.ts +++ b/src/lib/p-text-helpers.ts @@ -957,6 +957,8 @@ export function isPluralInflections(inf: T.PluralInflections | T.Inflections): i return inf.fem.length === 2; } + +// TODO: make this usable with things like endsWith([{ f: ["t", "b"] } | { ps: "ای", f: "aay" }]) /** * determines if ps ends with a given ending, or one of an array of given endings * (can be accent sensitive or not) @@ -966,16 +968,16 @@ export function isPluralInflections(inf: T.PluralInflections | T.Inflections): i * */ export function endsWith( - ending: T.PsString | T.PsString[] | { p: string | string[] } | { f: string | string[] }, + ending: (T.PsString | { p: string | string[] } | { f: string | string[] }) | (T.PsString | { p: string | string[] } | { f: string | string[] })[], ps?: boolean, ): (ps: T.PsString) => boolean; export function endsWith( - ending: T.PsString | T.PsString[] | { p: string | string[] } | { f: string | string[] }, + ending: (T.PsString | { p: string | string[] } | { f: string | string[] }) | (T.PsString | { p: string | string[] } | { f: string | string[] })[], ps: T.PsString, matchAccent?: boolean, ): boolean; export function endsWith( - ending: T.PsString | T.PsString[] | { p: string | string[] } | { f: string | string[] }, + ending: (T.PsString | { p: string | string[] } | { f: string | string[] }) | (T.PsString | { p: string | string[] } | { f: string | string[] })[], ps: T.PsString | undefined | boolean, matchAccent?: boolean | undefined, ): boolean | ((ps: T.PsString) => boolean) {