UNPKG

@enonic/js-utils

Version:
83 lines (82 loc) 2.98 kB
"use strict"; function _type_of(obj) { "@swc/helpers - typeof"; return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = function(target, all) { for(var name in all)__defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = function(to, from, except, desc) { if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") { var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; try { var _loop = function() { var key = _step.value; if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: function() { return from[key]; }, enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); }; for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop(); } catch (err) { _didIteratorError = true; _iteratorError = err; } finally{ try { if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } } finally{ if (_didIteratorError) { throw _iteratorError; } } } } return to; }; var __toCommonJS = function(mod) { return __copyProps(__defProp({}, "__esModule", { value: true }), mod); }; // storage/query/and.ts var and_exports = {}; __export(and_exports, { and: function() { return and; } }); module.exports = __toCommonJS(and_exports); // array/flatten.ts function flatten(arr) { var d = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1; return d > 0 ? arr.reduce(function(acc, val) { return acc.concat(Array.isArray(val) ? flatten(val, d - 1) : val); }, []) : arr.slice(); } // storage/query/constants.ts var QUERY_OPERATOR_AND = "AND"; // storage/query/and.ts function and() { for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){ args[_key] = arguments[_key]; } var flattened = flatten(args); if (Array.isArray(flattened)) { if (flattened.length === 1) { return "".concat(QUERY_OPERATOR_AND, " ").concat(flattened); } return flattened.join(" ".concat(QUERY_OPERATOR_AND, " ")); } return "".concat(QUERY_OPERATOR_AND, " ").concat(flattened); }