@livechat/accounts-sdk 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2003,7 +2003,7 @@
2003
2003
  var hexTable = function () {
2004
2004
  var array = [];
2005
2005
  for (var i = 0; i < 256; ++i) {
2006
- array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
2006
+ array[array.length] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
2007
2007
  }
2008
2008
  return array;
2009
2009
  }();
@@ -2015,7 +2015,7 @@
2015
2015
  var compacted = [];
2016
2016
  for (var j = 0; j < obj.length; ++j) {
2017
2017
  if (typeof obj[j] !== 'undefined') {
2018
- compacted.push(obj[j]);
2018
+ compacted[compacted.length] = obj[j];
2019
2019
  }
2020
2020
  }
2021
2021
  item.obj[item.prop] = compacted;
@@ -2040,13 +2040,19 @@
2040
2040
  }
2041
2041
  if (typeof source !== 'object' && typeof source !== 'function') {
2042
2042
  if (isArray(target)) {
2043
- target.push(source);
2043
+ var nextIndex = target.length;
2044
+ if (options && typeof options.arrayLimit === 'number' && nextIndex > options.arrayLimit) {
2045
+ return markOverflow(arrayToObject(target.concat(source), options), nextIndex);
2046
+ }
2047
+ target[nextIndex] = source;
2044
2048
  } else if (target && typeof target === 'object') {
2045
2049
  if (isOverflow(target)) {
2046
2050
  // Add at next numeric index for overflow objects
2047
2051
  var newIndex = getMaxIndex(target) + 1;
2048
2052
  target[newIndex] = source;
2049
2053
  setMaxIndex(target, newIndex);
2054
+ } else if (options && options.strictMerge) {
2055
+ return [target, source];
2050
2056
  } else if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
2051
2057
  target[source] = true;
2052
2058
  }
@@ -2071,7 +2077,11 @@
2071
2077
  }
2072
2078
  return markOverflow(result, getMaxIndex(source) + 1);
2073
2079
  }
2074
- return [target].concat(source);
2080
+ var combined = [target].concat(source);
2081
+ if (options && typeof options.arrayLimit === 'number' && combined.length > options.arrayLimit) {
2082
+ return markOverflow(arrayToObject(combined, options), combined.length - 1);
2083
+ }
2084
+ return combined;
2075
2085
  }
2076
2086
  var mergeTarget = target;
2077
2087
  if (isArray(target) && !isArray(source)) {
@@ -2084,7 +2094,7 @@
2084
2094
  if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
2085
2095
  target[i] = merge(targetItem, item, options);
2086
2096
  } else {
2087
- target.push(item);
2097
+ target[target.length] = item;
2088
2098
  }
2089
2099
  } else {
2090
2100
  target[i] = item;
@@ -2099,6 +2109,15 @@
2099
2109
  } else {
2100
2110
  acc[key] = value;
2101
2111
  }
2112
+ if (isOverflow(source) && !isOverflow(acc)) {
2113
+ markOverflow(acc, getMaxIndex(source));
2114
+ }
2115
+ if (isOverflow(acc)) {
2116
+ var keyNum = parseInt(key, 10);
2117
+ if (String(keyNum) === key && keyNum >= 0 && keyNum > getMaxIndex(acc)) {
2118
+ setMaxIndex(acc, keyNum);
2119
+ }
2120
+ }
2102
2121
  return acc;
2103
2122
  }, mergeTarget);
2104
2123
  };
@@ -2196,11 +2215,11 @@
2196
2215
  var key = keys[j];
2197
2216
  var val = obj[key];
2198
2217
  if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
2199
- queue.push({
2218
+ queue[queue.length] = {
2200
2219
  obj: obj,
2201
2220
  prop: key
2202
- });
2203
- refs.push(val);
2221
+ };
2222
+ refs[refs.length] = val;
2204
2223
  }
2205
2224
  }
2206
2225
  }
@@ -2236,7 +2255,7 @@
2236
2255
  if (isArray(val)) {
2237
2256
  var mapped = [];
2238
2257
  for (var i = 0; i < val.length; i += 1) {
2239
- mapped.push(fn(val[i]));
2258
+ mapped[mapped.length] = fn(val[i]);
2240
2259
  }
2241
2260
  return mapped;
2242
2261
  }
@@ -2252,6 +2271,7 @@
2252
2271
  isBuffer: isBuffer,
2253
2272
  isOverflow: isOverflow,
2254
2273
  isRegExp: isRegExp,
2274
+ markOverflow: markOverflow,
2255
2275
  maybeMap: maybeMap,
2256
2276
  merge: merge
2257
2277
  };
@@ -2538,6 +2558,7 @@
2538
2558
  parseArrays: true,
2539
2559
  plainObjects: false,
2540
2560
  strictDepth: false,
2561
+ strictMerge: true,
2541
2562
  strictNullHandling: false,
2542
2563
  throwOnLimitExceeded: false
2543
2564
  };
@@ -2572,7 +2593,7 @@
2572
2593
  };
2573
2594
  var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
2574
2595
  cleanStr = cleanStr.replace(/%5B/gi, '[').replace(/%5D/gi, ']');
2575
- var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
2596
+ var limit = options.parameterLimit === Infinity ? void undefined : options.parameterLimit;
2576
2597
  var parts = cleanStr.split(options.delimiter, options.throwOnLimitExceeded ? limit + 1 : limit);
2577
2598
  if (options.throwOnLimitExceeded && parts.length > limit) {
2578
2599
  throw new RangeError('Parameter limit exceeded. Only ' + limit + ' parameter' + (limit === 1 ? '' : 's') + ' allowed.');
@@ -2619,9 +2640,15 @@
2619
2640
  if (part.indexOf('[]=') > -1) {
2620
2641
  val = isArray(val) ? [val] : val;
2621
2642
  }
2643
+ if (options.comma && isArray(val) && val.length > options.arrayLimit) {
2644
+ if (options.throwOnLimitExceeded) {
2645
+ throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (options.arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
2646
+ }
2647
+ val = utils.combine([], val, options.arrayLimit, options.plainObjects);
2648
+ }
2622
2649
  if (key !== null) {
2623
2650
  var existing = has.call(obj, key);
2624
- if (existing && options.duplicates === 'combine') {
2651
+ if (existing && (options.duplicates === 'combine' || part.indexOf('[]=') > -1)) {
2625
2652
  obj[key] = utils.combine(obj[key], val, options.arrayLimit, options.plainObjects);
2626
2653
  } else if (!existing || options.duplicates === 'last') {
2627
2654
  obj[key] = val;
@@ -2654,13 +2681,19 @@
2654
2681
  var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
2655
2682
  var decodedRoot = options.decodeDotInKeys ? cleanRoot.replace(/%2E/g, '.') : cleanRoot;
2656
2683
  var index = parseInt(decodedRoot, 10);
2684
+ var isValidArrayIndex = !isNaN(index) && root !== decodedRoot && String(index) === decodedRoot && index >= 0 && options.parseArrays;
2657
2685
  if (!options.parseArrays && decodedRoot === '') {
2658
2686
  obj = {
2659
2687
  0: leaf
2660
2688
  };
2661
- } else if (!isNaN(index) && root !== decodedRoot && String(index) === decodedRoot && index >= 0 && options.parseArrays && index <= options.arrayLimit) {
2689
+ } else if (isValidArrayIndex && index < options.arrayLimit) {
2662
2690
  obj = [];
2663
2691
  obj[index] = leaf;
2692
+ } else if (isValidArrayIndex && options.throwOnLimitExceeded) {
2693
+ throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (options.arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
2694
+ } else if (isValidArrayIndex) {
2695
+ obj[index] = leaf;
2696
+ utils.markOverflow(obj, index);
2664
2697
  } else if (decodedRoot !== '__proto__') {
2665
2698
  obj[decodedRoot] = leaf;
2666
2699
  }
@@ -2690,7 +2723,7 @@
2690
2723
  return;
2691
2724
  }
2692
2725
  }
2693
- keys.push(parent);
2726
+ keys[keys.length] = parent;
2694
2727
  }
2695
2728
  var i = 0;
2696
2729
  while ((segment = child.exec(key)) !== null && i < options.depth) {
@@ -2701,13 +2734,13 @@
2701
2734
  return;
2702
2735
  }
2703
2736
  }
2704
- keys.push(segment[1]);
2737
+ keys[keys.length] = segment[1];
2705
2738
  }
2706
2739
  if (segment) {
2707
2740
  if (options.strictDepth === true) {
2708
2741
  throw new RangeError('Input depth exceeded depth option of ' + options.depth + ' and strictDepth is true');
2709
2742
  }
2710
- keys.push('[' + key.slice(segment.index) + ']');
2743
+ keys[keys.length] = '[' + key.slice(segment.index) + ']';
2711
2744
  }
2712
2745
  return keys;
2713
2746
  };
@@ -2767,6 +2800,7 @@
2767
2800
  parseArrays: opts.parseArrays !== false,
2768
2801
  plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
2769
2802
  strictDepth: typeof opts.strictDepth === 'boolean' ? !!opts.strictDepth : defaults.strictDepth,
2803
+ strictMerge: typeof opts.strictMerge === 'boolean' ? !!opts.strictMerge : defaults.strictMerge,
2770
2804
  strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling,
2771
2805
  throwOnLimitExceeded: typeof opts.throwOnLimitExceeded === 'boolean' ? opts.throwOnLimitExceeded : false
2772
2806
  };