UNPKG

@algolia/autocomplete-js

Version:

Fast and fully-featured autocomplete JavaScript library.

29 lines 2.29 kB
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } var isPlainObject = function isPlainObject(value) { return value && _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Object]'; }; export function mergeDeep() { for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) { values[_key] = arguments[_key]; } return values.reduce(function (acc, current) { Object.keys(current).forEach(function (key) { var accValue = acc[key]; var currentValue = current[key]; if (Array.isArray(accValue) && Array.isArray(currentValue)) { acc[key] = accValue.concat.apply(accValue, _toConsumableArray(currentValue)); } else if (isPlainObject(accValue) && isPlainObject(currentValue)) { acc[key] = mergeDeep(accValue, currentValue); } else { acc[key] = currentValue; } }); return acc; }, {}); }