UNPKG

handsontable

Version:

Handsontable is a JavaScript Data Grid available for React, Angular and Vue.

26 lines (24 loc) 1.76 kB
"use strict"; exports.__esModule = true; exports.operationResult = operationResult; require("core-js/modules/es.error.cause.js"); require("core-js/modules/esnext.iterator.constructor.js"); require("core-js/modules/esnext.iterator.some.js"); var C = _interopRequireWildcard(require("../../../i18n/constants")); var _logicalOperationRegisterer = require("../logicalOperationRegisterer"); function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } const OPERATION_ID = exports.OPERATION_ID = 'disjunctionWithExtraCondition'; const SHORT_NAME_FOR_COMPONENT = exports.SHORT_NAME_FOR_COMPONENT = C.FILTERS_LABELS_DISJUNCTION; // ((p OR q OR w OR x OR...) AND z) === TRUE? /** * @param {Array} conditions An array with values to check. * @param {*} value The comparable value. * @returns {boolean} */ function operationResult(conditions, value) { if (conditions.length < 3) { throw Error('Operation doesn\'t work on less then three conditions.'); } return conditions.slice(0, conditions.length - 1).some(condition => condition.func(value)) && conditions[conditions.length - 1].func(value); } (0, _logicalOperationRegisterer.registerOperation)(OPERATION_ID, SHORT_NAME_FOR_COMPONENT, operationResult);