From 44d2c4c8708dae8c07370b16d6ca5e7750369ddb Mon Sep 17 00:00:00 2001 From: Viren070 Date: Sat, 21 Jun 2025 02:20:15 +0100 Subject: [PATCH] feat: add 'not' function to BaseConditionParser for filtering streams --- packages/core/src/parser/conditions.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/core/src/parser/conditions.ts b/packages/core/src/parser/conditions.ts index 85d7be51..c9258d36 100644 --- a/packages/core/src/parser/conditions.ts +++ b/packages/core/src/parser/conditions.ts @@ -367,6 +367,19 @@ export abstract class BaseConditionParser { } return streams.length; }; + + this.parser.functions.not = function ( + streams: ParsedStream[], + originalStreams: ParsedStream[] + ) { + if (!Array.isArray(originalStreams)) { + throw new Error( + "Please use one of 'totalStreams' or 'previousStreams' as the second argument" + ); + } + const streamIds = new Set(streams.map((stream) => stream.id)); + return originalStreams.filter((stream) => !streamIds.has(stream.id)); + }; } protected async evaluateCondition(condition: string): Promise {