From c5b0b8e3ded80e8a0ed7bbf3e1f94e828e93ac34 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Tue, 11 Jun 2024 22:39:16 +0900 Subject: [PATCH] feat: improve filter --- src/ts/parser.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ts/parser.ts b/src/ts/parser.ts index 4c5e2891..03a8a1b0 100644 --- a/src/ts/parser.ts +++ b/src/ts/parser.ts @@ -1014,8 +1014,24 @@ const matcher = (p1:string,matcherArg:matcherArg) => { } case 'filter':{ const array = arra[1].split('§') + const filterTypes = [ + 'all', + 'nonempty', + 'unique', + ] + let filterType = filterTypes.indexOf(arra[2]) + if(filterType === -1){ + filterType = 0 + } return array.filter((f, i) => { - return f !== '' && i === array.indexOf(f) + switch(filterType){ + case 0: + return f !== '' && i === array.indexOf(f) + case 1: + return f !== '' + case 2: + return i === array.indexOf(f) + } }).join('§') } }