From dc0cd48015190d02ab6f3489203dc8a911ee4312 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Mon, 30 May 2022 15:23:02 -0500 Subject: [PATCH] improve flattenLengths --- package.json | 2 +- src/lib/phrase-building/segment.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 8141d8d..1b33106 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "2.6.7", + "version": "2.6.8", "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/phrase-building/segment.ts b/src/lib/phrase-building/segment.ts index a0c3da2..5833f0b 100644 --- a/src/lib/phrase-building/segment.ts +++ b/src/lib/phrase-building/segment.ts @@ -82,11 +82,14 @@ export function combineSegments(loe: (Segment | " " | "" | T.PsString)[], spaces ); } -export function flattenLengths(r: T.SingleOrLengthOpts): T.PsString[] { +export function flattenLengths(r: T.SingleOrLengthOpts): T.PsString[] { if ("long" in r) { return Object.values(r).flat(); } - return r; + if (Array.isArray(r)) { + return r; + } + return [r]; } export function putKidsInKidsSection(segments: Segment[], kids: Segment[]): Segment[] {