@rpcbase/api 0.132.0 → 0.133.0

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.
package/dist/index.js CHANGED
@@ -15226,6 +15226,7 @@ function requireUtils$1() {
15226
15226
  hasRequiredUtils$1 = 1;
15227
15227
  var formats2 = /* @__PURE__ */ requireFormats();
15228
15228
  var getSideChannel = requireSideChannel();
15229
+ var defineProperty = /* @__PURE__ */ requireEsDefineProperty();
15229
15230
  var has = Object.prototype.hasOwnProperty;
15230
15231
  var isArray = Array.isArray;
15231
15232
  var overflowChannel = getSideChannel();
@@ -15273,6 +15274,18 @@ function requireUtils$1() {
15273
15274
  }
15274
15275
  return obj;
15275
15276
  };
15277
+ var setProperty = function setProperty2(obj, key, value) {
15278
+ if (key === "__proto__" && defineProperty) {
15279
+ defineProperty(obj, key, {
15280
+ configurable: true,
15281
+ enumerable: true,
15282
+ value,
15283
+ writable: true
15284
+ });
15285
+ } else {
15286
+ obj[key] = value;
15287
+ }
15288
+ };
15276
15289
  var merge = function merge2(target, source, options) {
15277
15290
  if (!source) {
15278
15291
  return target;
@@ -15280,7 +15293,10 @@ function requireUtils$1() {
15280
15293
  if (typeof source !== "object" && typeof source !== "function") {
15281
15294
  if (isArray(target)) {
15282
15295
  var nextIndex = target.length;
15283
- if (options && typeof options.arrayLimit === "number" && nextIndex > options.arrayLimit) {
15296
+ if (options && typeof options.arrayLimit === "number" && nextIndex >= options.arrayLimit) {
15297
+ if (options.throwOnLimitExceeded) {
15298
+ throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
15299
+ }
15284
15300
  return markOverflow(arrayToObject(target.concat(source), options), nextIndex);
15285
15301
  }
15286
15302
  target[nextIndex] = source;
@@ -15311,6 +15327,9 @@ function requireUtils$1() {
15311
15327
  }
15312
15328
  var combined = [target].concat(source);
15313
15329
  if (options && typeof options.arrayLimit === "number" && combined.length > options.arrayLimit) {
15330
+ if (options.throwOnLimitExceeded) {
15331
+ throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
15332
+ }
15314
15333
  return markOverflow(arrayToObject(combined, options), combined.length - 1);
15315
15334
  }
15316
15335
  return combined;
@@ -15332,14 +15351,20 @@ function requireUtils$1() {
15332
15351
  target[i] = item;
15333
15352
  }
15334
15353
  });
15354
+ if (options && typeof options.arrayLimit === "number" && target.length > options.arrayLimit) {
15355
+ if (options.throwOnLimitExceeded) {
15356
+ throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
15357
+ }
15358
+ return markOverflow(arrayToObject(target, options), target.length - 1);
15359
+ }
15335
15360
  return target;
15336
15361
  }
15337
15362
  return Object.keys(source).reduce(function(acc, key) {
15338
15363
  var value = source[key];
15339
15364
  if (has.call(acc, key)) {
15340
- acc[key] = merge2(acc[key], value, options);
15365
+ setProperty(acc, key, merge2(acc[key], value, options));
15341
15366
  } else {
15342
- acc[key] = value;
15367
+ setProperty(acc, key, value);
15343
15368
  }
15344
15369
  if (isOverflow(source) && !isOverflow(acc)) {
15345
15370
  markOverflow(acc, getMaxIndex(source));
@@ -15355,7 +15380,7 @@ function requireUtils$1() {
15355
15380
  };
15356
15381
  var assign = function assignSingleSource(target, source) {
15357
15382
  return Object.keys(source).reduce(function(acc, key) {
15358
- acc[key] = source[key];
15383
+ setProperty(acc, key, source[key]);
15359
15384
  return acc;
15360
15385
  }, target);
15361
15386
  };
@@ -15389,6 +15414,13 @@ function requireUtils$1() {
15389
15414
  var out = "";
15390
15415
  for (var j = 0; j < string.length; j += limit) {
15391
15416
  var segment = string.length >= limit ? string.slice(j, j + limit) : string;
15417
+ if (j + limit < string.length) {
15418
+ var last = segment.charCodeAt(segment.length - 1);
15419
+ if (last >= 55296 && last <= 56319) {
15420
+ segment = segment.slice(0, -1);
15421
+ j -= 1;
15422
+ }
15423
+ }
15392
15424
  var arr = [];
15393
15425
  for (var i = 0; i < segment.length; ++i) {
15394
15426
  var c = segment.charCodeAt(i);
@@ -15418,7 +15450,7 @@ function requireUtils$1() {
15418
15450
  };
15419
15451
  var compact = function compact2(value) {
15420
15452
  var queue = [{ obj: { o: value }, prop: "o" }];
15421
- var refs = [];
15453
+ var refs = getSideChannel();
15422
15454
  for (var i = 0; i < queue.length; ++i) {
15423
15455
  var item = queue[i];
15424
15456
  var obj = item.obj[item.prop];
@@ -15426,9 +15458,9 @@ function requireUtils$1() {
15426
15458
  for (var j = 0; j < keys.length; ++j) {
15427
15459
  var key = keys[j];
15428
15460
  var val = obj[key];
15429
- if (typeof val === "object" && val !== null && refs.indexOf(val) === -1) {
15461
+ if (typeof val === "object" && val !== null && !refs.has(val)) {
15430
15462
  queue[queue.length] = { obj, prop: key };
15431
- refs[refs.length] = val;
15463
+ refs.set(val, true);
15432
15464
  }
15433
15465
  }
15434
15466
  }
@@ -15444,8 +15476,11 @@ function requireUtils$1() {
15444
15476
  }
15445
15477
  return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
15446
15478
  };
15447
- var combine = function combine2(a, b, arrayLimit, plainObjects) {
15479
+ var combine = function combine2(a, b, arrayLimit, plainObjects, throwOnLimitExceeded) {
15448
15480
  if (isOverflow(a)) {
15481
+ if (throwOnLimitExceeded) {
15482
+ throw new RangeError("Array limit exceeded. Only " + arrayLimit + " element" + (arrayLimit === 1 ? "" : "s") + " allowed in an array.");
15483
+ }
15449
15484
  var newIndex = getMaxIndex(a) + 1;
15450
15485
  a[newIndex] = b;
15451
15486
  setMaxIndex(a, newIndex);
@@ -15453,6 +15488,9 @@ function requireUtils$1() {
15453
15488
  }
15454
15489
  var result = [].concat(a, b);
15455
15490
  if (result.length > arrayLimit) {
15491
+ if (throwOnLimitExceeded) {
15492
+ throw new RangeError("Array limit exceeded. Only " + arrayLimit + " element" + (arrayLimit === 1 ? "" : "s") + " allowed in an array.");
15493
+ }
15456
15494
  return markOverflow(arrayToObject(result, { plainObjects }), result.length - 1);
15457
15495
  }
15458
15496
  return result;
@@ -15808,8 +15846,19 @@ function requireParse() {
15808
15846
  return String.fromCharCode(parseInt(numberStr, 10));
15809
15847
  });
15810
15848
  };
15811
- var parseArrayValue = function(val, options, currentArrayLength) {
15849
+ var parseArrayValue = function(val, options, currentArrayLength, isFlatArrayValue) {
15812
15850
  if (val && typeof val === "string" && options.comma && val.indexOf(",") > -1) {
15851
+ if (isFlatArrayValue && options.throwOnLimitExceeded) {
15852
+ var commaCount = 0;
15853
+ var commaIndex = val.indexOf(",");
15854
+ while (commaIndex > -1) {
15855
+ commaCount += 1;
15856
+ if (commaCount >= options.arrayLimit) {
15857
+ throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
15858
+ }
15859
+ commaIndex = val.indexOf(",", commaIndex + 1);
15860
+ }
15861
+ }
15813
15862
  return val.split(",");
15814
15863
  }
15815
15864
  if (options.throwOnLimitExceeded && currentArrayLength >= options.arrayLimit) {
@@ -15866,7 +15915,8 @@ function requireParse() {
15866
15915
  parseArrayValue(
15867
15916
  part.slice(pos + 1),
15868
15917
  options,
15869
- isArray(obj[key]) ? obj[key].length : 0
15918
+ isArray(obj[key]) ? obj[key].length : 0,
15919
+ part.indexOf("[]=") === -1
15870
15920
  ),
15871
15921
  function(encodedVal) {
15872
15922
  return options.decoder(encodedVal, defaults.decoder, charset2, "value");
@@ -15881,10 +15931,7 @@ function requireParse() {
15881
15931
  val = isArray(val) ? [val] : val;
15882
15932
  }
15883
15933
  if (options.comma && isArray(val) && val.length > options.arrayLimit) {
15884
- if (options.throwOnLimitExceeded) {
15885
- throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
15886
- }
15887
- val = utils2.combine([], val, options.arrayLimit, options.plainObjects);
15934
+ val = utils2.combine([], val, options.arrayLimit, options.plainObjects, options.throwOnLimitExceeded);
15888
15935
  }
15889
15936
  if (key !== null) {
15890
15937
  var existing = has.call(obj, key);
@@ -15893,7 +15940,8 @@ function requireParse() {
15893
15940
  obj[key],
15894
15941
  val,
15895
15942
  options.arrayLimit,
15896
- options.plainObjects
15943
+ options.plainObjects,
15944
+ options.throwOnLimitExceeded
15897
15945
  );
15898
15946
  } else if (!existing || options.duplicates === "last") {
15899
15947
  obj[key] = val;
@@ -15920,7 +15968,8 @@ function requireParse() {
15920
15968
  [],
15921
15969
  leaf,
15922
15970
  options.arrayLimit,
15923
- options.plainObjects
15971
+ options.plainObjects,
15972
+ options.throwOnLimitExceeded
15924
15973
  );
15925
15974
  }
15926
15975
  } else {
@@ -19770,19 +19819,27 @@ function requireRangeParser() {
19770
19819
  var ranges = [];
19771
19820
  ranges.type = str.slice(0, index);
19772
19821
  for (var i = 0; i < arr.length; i++) {
19773
- var range2 = arr[i].split("-");
19774
- var start = parseInt(range2[0], 10);
19775
- var end = parseInt(range2[1], 10);
19776
- if (isNaN(start)) {
19822
+ var indexOf = arr[i].indexOf("-");
19823
+ if (indexOf === -1) {
19824
+ return -2;
19825
+ }
19826
+ var startStr = arr[i].slice(0, indexOf).trim();
19827
+ var endStr = arr[i].slice(indexOf + 1).trim();
19828
+ var start = parsePos(startStr);
19829
+ var end = parsePos(endStr);
19830
+ if (startStr.length === 0) {
19777
19831
  start = size - end;
19778
19832
  end = size - 1;
19779
- } else if (isNaN(end)) {
19833
+ } else if (endStr.length === 0) {
19780
19834
  end = size - 1;
19781
19835
  }
19782
19836
  if (end > size - 1) {
19783
19837
  end = size - 1;
19784
19838
  }
19785
- if (isNaN(start) || isNaN(end) || start > end || start < 0) {
19839
+ if (isNaN(start) || isNaN(end)) {
19840
+ return -2;
19841
+ }
19842
+ if (start > end || start < 0) {
19786
19843
  continue;
19787
19844
  }
19788
19845
  ranges.push({
@@ -19795,6 +19852,10 @@ function requireRangeParser() {
19795
19852
  }
19796
19853
  return options && options.combine ? combineRanges(ranges) : ranges;
19797
19854
  }
19855
+ function parsePos(str) {
19856
+ if (/^\d+$/.test(str)) return Number(str);
19857
+ return NaN;
19858
+ }
19798
19859
  function combineRanges(ranges) {
19799
19860
  var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart);
19800
19861
  for (var j = 0, i = 1; i < ordered.length; i++) {