From 571b498658425f3a9c8a837b270b0b654830b327 Mon Sep 17 00:00:00 2001 From: cha0s Date: Tue, 28 May 2019 16:51:05 -0500 Subject: [PATCH] feat: contains condition op --- packages/behavior/item/condition.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/behavior/item/condition.js b/packages/behavior/item/condition.js index 7b5fe0c..bf10d87 100644 --- a/packages/behavior/item/condition.js +++ b/packages/behavior/item/condition.js @@ -65,6 +65,14 @@ export class Condition { } return true; + case 'contains': + if (this.operands.length < 2) { + return false; + } + const haystack = this.operands[0].get(context); + const needle = this.operands[1].get(context); + return -1 !== haystack.indexOf(needle); + } }