node-red-contrib-home-assistant-websocket
Version:
Node-RED integration with Home Assistant through websocket and REST API
2 lines (1 loc) • 1.54 kB
JavaScript
;var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var p=(s,r)=>{for(var e in r)i(s,e,{get:r[e],enumerable:!0})},m=(s,r,e,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of c(r))!a.call(s,o)&&o!==e&&i(s,o,{get:()=>r[o],enumerable:!(u=l(r,o))||u.enumerable});return s};var w=s=>m(i({},"__esModule",{value:!0}),s);var d={};p(d,{simpleComparison:()=>I});module.exports=w(d);var n=require("../../const"),t=require("../../helpers/assert");function I(s,r,e,u){switch(s){case n.ComparatorType.Is:return r===e;case n.ComparatorType.IsNot:return r!==e;case n.ComparatorType.Contains:return Array.isArray(r)&&r.includes(e);case n.ComparatorType.DoesNotContain:return Array.isArray(r)&&!r.includes(e);case n.ComparatorType.Includes:return(0,t.isString)(r)&&(0,t.isString)(e)&&e.split(",").map(o=>o.trim()).includes(r);case n.ComparatorType.DoesNotInclude:return(0,t.isString)(r)&&(0,t.isString)(e)&&!e.split(",").map(o=>o.trim()).includes(r);case n.ComparatorType.StartsWith:return(0,t.isString)(r)&&(0,t.isString)(e)&&r.startsWith(e);case n.ComparatorType.IsNull:return r===null;case n.ComparatorType.IsNotNull:return r!==null;case n.ComparatorType.IsTrue:return r===!0;case n.ComparatorType.IsFalse:return r===!1;case n.ComparatorType.Regex:return(0,t.isString)(r)&&(0,t.isString)(e)&&(0,t.isBoolean)(u)&&new RegExp(e,u?"i":"").test(r);default:throw new Error(`Unknown comparator type: ${s}`)}}0&&(module.exports={simpleComparison});