UNPKG

node-red-contrib-home-assistant-websocket

Version:
20 lines (19 loc) 879 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sortConditions = sortConditions; const const_1 = require("../../common/const"); function sortConditions(conditions) { const order = [ const_1.PropertySelectorType.Label, const_1.PropertySelectorType.State, const_1.PropertySelectorType.Device, const_1.PropertySelectorType.Area, const_1.PropertySelectorType.Floor, ]; return conditions.sort((a, b) => { var _a, _b; const aIndex = order.indexOf((_a = a === null || a === void 0 ? void 0 : a.condition) !== null && _a !== void 0 ? _a : const_1.PropertySelectorType.State); const bIndex = order.indexOf((_b = b === null || b === void 0 ? void 0 : b.condition) !== null && _b !== void 0 ? _b : const_1.PropertySelectorType.State); return aIndex - bIndex; }); }