{"ScriptPreparationCode":null,"TestCases":[{"Name":"foreach","Code":"const record = {\r\n subscriptions: [{\r\n events: [\r\n \u0027df\u0027,\r\n \u0027ff\u0027,\r\n \u0027gf\u0027,\r\n \u0027hf\u0027,\r\n \u0027rf\u0027,\r\n \u0027wf\u0027,\r\n ],\r\n }, {\r\n events: [\r\n \u0027df\u0027,\r\n \u0027ff\u0027,\r\n \u0027gf\u0027,\r\n \u0027hf\u0027,\r\n \u0027rf\u0027,\r\n \u0027wf\u0027,\r\n ],\r\n }, {\r\n events: [\r\n \u0027df\u0027,\r\n \u0027ff\u0027,\r\n \u0027gf\u0027,\r\n \u0027hf\u0027,\r\n \u0027rf\u0027,\r\n \u0027wf\u0027,\r\n ],\r\n }, {\r\n events: [\r\n \u0027df\u0027,\r\n \u0027ff\u0027,\r\n \u0027gf\u0027,\r\n \u0027hf\u0027,\r\n \u0027rf\u0027,\r\n \u0027aa\u0027,\r\n ],\r\n }, ],\r\n};\r\nconst isSubscribed = (subscriptionRecord, eventType) =\u003E {\r\n const {\r\n subscriptions\r\n } = subscriptionRecord;\r\n const events = [];\r\n subscriptions.forEach(s =\u003E {\r\n events.push(...s.events);\r\n });\r\n\r\n return _.includes(events, eventType);\r\n};\r\n\r\nconst result = isSubscribed(record, \u0027aa\u0027);","IsDeferred":false},{"Name":"flatten","Code":"const record = {\r\n subscriptions: [{\r\n events: [\r\n \u0027df\u0027,\r\n \u0027ff\u0027,\r\n \u0027gf\u0027,\r\n \u0027hf\u0027,\r\n \u0027rf\u0027,\r\n \u0027wf\u0027,\r\n ],\r\n }, {\r\n events: [\r\n \u0027df\u0027,\r\n \u0027ff\u0027,\r\n \u0027gf\u0027,\r\n \u0027hf\u0027,\r\n \u0027rf\u0027,\r\n \u0027wf\u0027,\r\n ],\r\n }, {\r\n events: [\r\n \u0027df\u0027,\r\n \u0027ff\u0027,\r\n \u0027gf\u0027,\r\n \u0027hf\u0027,\r\n \u0027rf\u0027,\r\n \u0027wf\u0027,\r\n ],\r\n }, {\r\n events: [\r\n \u0027df\u0027,\r\n \u0027ff\u0027,\r\n \u0027gf\u0027,\r\n \u0027hf\u0027,\r\n \u0027rf\u0027,\r\n \u0027aa\u0027,\r\n ],\r\n }, ],\r\n};\r\nconst isSubscribed3 = (subscriptionRecord, eventType) =\u003E {\r\n const events = _.flatten(subscriptionRecord.subscriptions.map(s =\u003E s.events))\r\n return _.includes(events, eventType);\r\n};\r\n\r\nconst result = isSubscribed3(record, \u0027aa\u0027);","IsDeferred":false},{"Name":"some","Code":"const record = {\r\n subscriptions: [{\r\n events: [\r\n \u0027df\u0027,\r\n \u0027ff\u0027,\r\n \u0027gf\u0027,\r\n \u0027hf\u0027,\r\n \u0027rf\u0027,\r\n \u0027wf\u0027,\r\n ],\r\n }, {\r\n events: [\r\n \u0027df\u0027,\r\n \u0027ff\u0027,\r\n \u0027gf\u0027,\r\n \u0027hf\u0027,\r\n \u0027rf\u0027,\r\n \u0027wf\u0027,\r\n ],\r\n }, {\r\n events: [\r\n \u0027df\u0027,\r\n \u0027ff\u0027,\r\n \u0027gf\u0027,\r\n \u0027hf\u0027,\r\n \u0027rf\u0027,\r\n \u0027wf\u0027,\r\n ],\r\n }, {\r\n events: [\r\n \u0027df\u0027,\r\n \u0027ff\u0027,\r\n \u0027gf\u0027,\r\n \u0027hf\u0027,\r\n \u0027rf\u0027,\r\n \u0027aa\u0027,\r\n ],\r\n }, ],\r\n};\r\nconst isSubscribed2 = (subscriptionRecord, eventType) =\u003E {\r\n return _.some(subscriptionRecord.subscriptions, sub =\u003E _.includes(sub.events, eventType))\r\n};\r\nconst t = isSubscribed2(record, \u0027aa\u0027);","IsDeferred":false}]}