ignoring ' in endsWith, but its type sketchy
This commit is contained in:
parent
31c5b3b4e8
commit
c1fd83b8de
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lingdocs/pashto-inflector",
|
||||
"version": "1.2.4",
|
||||
"version": "1.2.5",
|
||||
"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",
|
||||
|
|
|
@ -1156,6 +1156,11 @@ test("endsWith", () => {
|
|||
.toBe(true);
|
||||
expect(endsWith({ p: ["ډ", "د"] }, { p: "چت", f: "chat" }))
|
||||
.toBe(false);
|
||||
// ignore '
|
||||
expect(endsWith({ p: "ا", f: "aa" }, { p: "اعدا", f: "idaa'" }))
|
||||
.toBe(true);
|
||||
expect(endsWith({ p: "ا", f: "aa'" }, { p: "اعدا", f: "idaa" }))
|
||||
.toBe(true);
|
||||
// ability to curry
|
||||
expect(endsWith({ p: "ی", f: "ey" })({ p: "سړی", f: "saRéy" }))
|
||||
.toBe(true);
|
||||
|
|
|
@ -995,12 +995,16 @@ export function endsWith(
|
|||
if ("f" in ending && Array.isArray(ending.f)) {
|
||||
return ending.f.some(e => endsWith({ f: e }, ps));
|
||||
}
|
||||
const f = removeFVarients(ps.f);
|
||||
const f = removeFVarients(ps.f).replace(/'/g, "");
|
||||
const fEnd = "f" in ending
|
||||
// @ts-ignore
|
||||
? ending.f.replace(/'/g, "")
|
||||
: undefined;
|
||||
return (
|
||||
(("p" in ending) ? ps.p.slice(-ending.p.length) === ending.p : true)
|
||||
&&
|
||||
(("f" in ending) ?
|
||||
((matchAccent ? f.slice(-ending.f.length) : removeAccents(f.slice(-ending.f.length))) === ending.f)
|
||||
((fEnd) ?
|
||||
((matchAccent ? f.slice(-fEnd.length) : removeAccents(f.slice(-fEnd.length))) === fEnd)
|
||||
: true)
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue