Created
June 26, 2020 03:06
-
-
Save weird-coon/9b7186917001161f577bacb0880ca641 to your computer and use it in GitHub Desktop.
Get single Element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getSpSingleItems(petState: TextValue[]): string[] { | |
const filterState: TextValue[] = [...petState].reverse() | |
let i: number = filterState.length | |
while (i--) { | |
if (i - 1 >= 0) { // remove element if 2 continue is normal item | |
if (!filterState[i].longText && !filterState[i - 1].longText) { | |
filterState.splice(i, 1) | |
filterState.splice(i - 1, 1) | |
i = i - 1 | |
} | |
} | |
} | |
return filterState.filter((item: any) => !item!.longText) // remove long item | |
.map((item: any) => item.name) // single element item name | |
} | |
isSingleItem(name: string): boolean { | |
return this.spSingleItems.includes(name) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment