@lowentry/utils 1.20.1 → 1.21.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.
package/index.js CHANGED
@@ -3034,6 +3034,15 @@ var LeUtils = {
3034
3034
  * @returns {boolean}
3035
3035
  */
3036
3036
  isGivenHostPrivate: function isGivenHostPrivate(host) {
3037
+ host = STRING(host).trim();
3038
+ if (!host) {
3039
+ return false;
3040
+ }
3041
+ try {
3042
+ host = new URL(host).hostname;
3043
+ } catch (e) {
3044
+ host = host.split(':')[0];
3045
+ }
3037
3046
  host = STRING(host).trim().toLowerCase();
3038
3047
  if (host === 'localhost' || host === '127.0.0.1') {
3039
3048
  return true;
@@ -3048,178 +3057,6 @@ var LeUtils = {
3048
3057
  // 172.16.0.0 - 172.31.255.255
3049
3058
  parts[0] === '192' && parts[1] === '168'; // 192.168.0.0 - 192.168.255.255
3050
3059
  },
3051
- /**
3052
- * Creates and returns a new TreeSet.
3053
- * A TreeSet is a set of elements, sorted by a comparator.
3054
- * Binary search is used to find elements, which makes it very fast to find elements.
3055
- *
3056
- * The comparator is also used to determine if two values are equal to each other.
3057
- * This way, you can have values that aren't the same be treated as if they are. This can be used to deal with issues such as floating point errors for example.
3058
- *
3059
- * @param {*[]} elements
3060
- * @param {(valueA:*, valueB:*) => number} comparator
3061
- * @returns {{getElements:(()=>*[]), getComparator:(()=>((valueA:*,valueB:*)=>number)), size:(()=>number), isEmpty:(()=>boolean), contains:((value:*)=>boolean), first:(()=>*|undefined), last:(()=>*|undefined), pollFirst:(()=>*|undefined), pollLast:(()=>*|undefined), add:((value:*)=>void), addAll:((values:*)=>void), getEqualValue:((value:*)=>*), getEqualValueOrAdd:((value:*)=>*)}}
3062
- */
3063
- createTreeSet: function createTreeSet(elements, comparator) {
3064
- comparator = comparator || LeUtils.compare;
3065
- elements = elements || [];
3066
- elements.sort(comparator);
3067
-
3068
- /**
3069
- * Performs a binary search on the elements, and returns the result.
3070
- *
3071
- * @param {*} value
3072
- * @returns {{found: boolean, index: number, value: *|undefined}}
3073
- */
3074
- var binarySearch = function binarySearch(value) {
3075
- var low = 0;
3076
- var high = elements.length - 1;
3077
- while (low <= high) {
3078
- var mid = Math.floor((low + high) / 2);
3079
- var midValue = elements[mid];
3080
- var cmp = comparator(midValue, value);
3081
- if (cmp < 0) {
3082
- low = mid + 1;
3083
- } else if (cmp > 0) {
3084
- high = mid - 1;
3085
- } else {
3086
- return {
3087
- found: true,
3088
- index: mid,
3089
- value: midValue
3090
- };
3091
- }
3092
- }
3093
- return {
3094
- found: false,
3095
- index: low,
3096
- value: undefined
3097
- };
3098
- };
3099
- var treeSet = {
3100
- /**
3101
- * Returns the elements of the set.
3102
- *
3103
- * @returns {*[]}
3104
- */
3105
- getElements: function getElements() {
3106
- return elements;
3107
- },
3108
- /**
3109
- * Returns the comparator of the set.
3110
- *
3111
- * @returns {(valueA:*, valueB:*) => number}
3112
- */
3113
- getComparator: function getComparator() {
3114
- return comparator;
3115
- },
3116
- /**
3117
- * Returns the size of the set.
3118
- *
3119
- * @returns {number}
3120
- */
3121
- size: function size() {
3122
- return elements.length;
3123
- },
3124
- /**
3125
- * Returns true if the set is empty, false otherwise.
3126
- *
3127
- * @returns {boolean}
3128
- */
3129
- isEmpty: function isEmpty() {
3130
- return elements.length <= 0;
3131
- },
3132
- /**
3133
- * Returns true if the set contains a value that is equal to the given value, returns false otherwise.
3134
- *
3135
- * @param {*} value
3136
- * @returns {boolean}
3137
- */
3138
- contains: function contains(value) {
3139
- return binarySearch(value).found;
3140
- },
3141
- /**
3142
- * Returns the first element of the set, or undefined if it is empty.
3143
- *
3144
- * @returns {*|undefined}
3145
- */
3146
- first: function first() {
3147
- return elements.length > 0 ? elements[0] : undefined;
3148
- },
3149
- /**
3150
- * Returns the last element of the set, or undefined if it is empty.
3151
- *
3152
- * @returns {*|undefined}
3153
- */
3154
- last: function last() {
3155
- return elements.length > 0 ? elements[elements.length - 1] : undefined;
3156
- },
3157
- /**
3158
- * Removes and returns the first element of the set, or undefined if it is empty.
3159
- *
3160
- * @returns {*|undefined}
3161
- */
3162
- pollFirst: function pollFirst() {
3163
- return elements.length > 0 ? elements.splice(0, 1)[0] : undefined;
3164
- },
3165
- /**
3166
- * Removes and returns the last element of the set, or undefined if it is empty.
3167
- *
3168
- * @returns {*|undefined}
3169
- */
3170
- pollLast: function pollLast() {
3171
- return elements.length > 0 ? elements.splice(elements.length - 1, 1)[0] : undefined;
3172
- },
3173
- /**
3174
- * Adds the given value to the set. Will only do so if no equal value already exists.
3175
- *
3176
- * @param {*} value
3177
- */
3178
- add: function add(value) {
3179
- var result = binarySearch(value);
3180
- if (result.found) {
3181
- return;
3182
- }
3183
- elements.splice(result.index, 0, value);
3184
- },
3185
- /**
3186
- * Adds all the given values to the set. Will only do so if no equal value already exists.
3187
- *
3188
- * @param {*} values
3189
- */
3190
- addAll: function addAll(values) {
3191
- LeUtils.each(values, treeSet.add);
3192
- },
3193
- /**
3194
- * Returns an equal value that's already in the tree set, or undefined if no equal values in it exist.
3195
- *
3196
- * @param {*} value
3197
- * @returns {*|undefined}
3198
- */
3199
- getEqualValue: function getEqualValue(value) {
3200
- var result = binarySearch(value);
3201
- if (result.found) {
3202
- return result.value;
3203
- }
3204
- return undefined;
3205
- },
3206
- /**
3207
- * Returns an equal value that's already in the tree set. If no equal values in it exist, the given value will be added and returned.
3208
- *
3209
- * @param {*} value
3210
- * @returns {*}
3211
- */
3212
- getEqualValueOrAdd: function getEqualValueOrAdd(value) {
3213
- var result = binarySearch(value);
3214
- if (result.found) {
3215
- return result.value;
3216
- }
3217
- elements.splice(result.index, 0, value);
3218
- return value;
3219
- }
3220
- };
3221
- return treeSet;
3222
- },
3223
3060
  /**
3224
3061
  * @typedef {Object} LeUtils_TransactionalValue
3225
3062
  * @property {*} value
@@ -3588,11 +3425,11 @@ var LeUtils = {
3588
3425
  }()
3589
3426
  };
3590
3427
 
3591
- function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
3592
- function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3593
- function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
3594
- function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
3595
- function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
3428
+ function _classPrivateFieldInitSpec$1(e, t, a) { _checkPrivateRedeclaration$1(e, t), t.set(e, a); }
3429
+ function _checkPrivateRedeclaration$1(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3430
+ function _classPrivateFieldSet$1(s, a, r) { return s.set(_assertClassBrand$1(s, a), r), r; }
3431
+ function _classPrivateFieldGet$1(s, a) { return s.get(_assertClassBrand$1(s, a)); }
3432
+ function _assertClassBrand$1(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
3596
3433
  var LinkedListNode = /*#__PURE__*/_createClass(
3597
3434
  /**
3598
3435
  * @param {*} value
@@ -3614,11 +3451,11 @@ var LinkedList = /*#__PURE__*/function () {
3614
3451
  function LinkedList() {
3615
3452
  _classCallCheck(this, LinkedList);
3616
3453
  /** @type {LinkedListNode|null} */
3617
- _classPrivateFieldInitSpec(this, _head, null);
3454
+ _classPrivateFieldInitSpec$1(this, _head, null);
3618
3455
  /** @type {LinkedListNode|null} */
3619
- _classPrivateFieldInitSpec(this, _tail, null);
3456
+ _classPrivateFieldInitSpec$1(this, _tail, null);
3620
3457
  /** @type {number} */
3621
- _classPrivateFieldInitSpec(this, _size, 0);
3458
+ _classPrivateFieldInitSpec$1(this, _size, 0);
3622
3459
  }
3623
3460
 
3624
3461
  /**
@@ -3629,7 +3466,7 @@ var LinkedList = /*#__PURE__*/function () {
3629
3466
  return _createClass(LinkedList, [{
3630
3467
  key: "size",
3631
3468
  get: function get() {
3632
- return _classPrivateFieldGet(_size, this);
3469
+ return _classPrivateFieldGet$1(_size, this);
3633
3470
  }
3634
3471
 
3635
3472
  /**
@@ -3642,15 +3479,15 @@ var LinkedList = /*#__PURE__*/function () {
3642
3479
  value: function unshift(value) {
3643
3480
  var _this$size;
3644
3481
  var newNode = new LinkedListNode(value);
3645
- if (_classPrivateFieldGet(_head, this) === null) {
3646
- _classPrivateFieldSet(_head, this, newNode);
3647
- _classPrivateFieldSet(_tail, this, newNode);
3482
+ if (_classPrivateFieldGet$1(_head, this) === null) {
3483
+ _classPrivateFieldSet$1(_head, this, newNode);
3484
+ _classPrivateFieldSet$1(_tail, this, newNode);
3648
3485
  } else {
3649
- newNode.next = _classPrivateFieldGet(_head, this);
3650
- _classPrivateFieldGet(_head, this).previous = newNode;
3651
- _classPrivateFieldSet(_head, this, newNode);
3486
+ newNode.next = _classPrivateFieldGet$1(_head, this);
3487
+ _classPrivateFieldGet$1(_head, this).previous = newNode;
3488
+ _classPrivateFieldSet$1(_head, this, newNode);
3652
3489
  }
3653
- _classPrivateFieldSet(_size, this, (_this$size = _classPrivateFieldGet(_size, this), _this$size++, _this$size));
3490
+ _classPrivateFieldSet$1(_size, this, (_this$size = _classPrivateFieldGet$1(_size, this), _this$size++, _this$size));
3654
3491
  }
3655
3492
 
3656
3493
  /**
@@ -3663,15 +3500,15 @@ var LinkedList = /*#__PURE__*/function () {
3663
3500
  value: function push(value) {
3664
3501
  var _this$size3;
3665
3502
  var newNode = new LinkedListNode(value);
3666
- if (_classPrivateFieldGet(_tail, this) === null) {
3667
- _classPrivateFieldSet(_head, this, newNode);
3668
- _classPrivateFieldSet(_tail, this, newNode);
3503
+ if (_classPrivateFieldGet$1(_tail, this) === null) {
3504
+ _classPrivateFieldSet$1(_head, this, newNode);
3505
+ _classPrivateFieldSet$1(_tail, this, newNode);
3669
3506
  } else {
3670
- newNode.previous = _classPrivateFieldGet(_tail, this);
3671
- _classPrivateFieldGet(_tail, this).next = newNode;
3672
- _classPrivateFieldSet(_tail, this, newNode);
3507
+ newNode.previous = _classPrivateFieldGet$1(_tail, this);
3508
+ _classPrivateFieldGet$1(_tail, this).next = newNode;
3509
+ _classPrivateFieldSet$1(_tail, this, newNode);
3673
3510
  }
3674
- _classPrivateFieldSet(_size, this, (_this$size3 = _classPrivateFieldGet(_size, this), _this$size3++, _this$size3));
3511
+ _classPrivateFieldSet$1(_size, this, (_this$size3 = _classPrivateFieldGet$1(_size, this), _this$size3++, _this$size3));
3675
3512
  }
3676
3513
 
3677
3514
  /**
@@ -3683,17 +3520,17 @@ var LinkedList = /*#__PURE__*/function () {
3683
3520
  key: "shift",
3684
3521
  value: function shift() {
3685
3522
  var _this$size5;
3686
- if (_classPrivateFieldGet(_head, this) === null) {
3523
+ if (_classPrivateFieldGet$1(_head, this) === null) {
3687
3524
  return undefined;
3688
3525
  }
3689
- var value = _classPrivateFieldGet(_head, this).value;
3690
- _classPrivateFieldSet(_head, this, _classPrivateFieldGet(_head, this).next);
3691
- if (_classPrivateFieldGet(_head, this) !== null) {
3692
- _classPrivateFieldGet(_head, this).previous = null;
3526
+ var value = _classPrivateFieldGet$1(_head, this).value;
3527
+ _classPrivateFieldSet$1(_head, this, _classPrivateFieldGet$1(_head, this).next);
3528
+ if (_classPrivateFieldGet$1(_head, this) !== null) {
3529
+ _classPrivateFieldGet$1(_head, this).previous = null;
3693
3530
  } else {
3694
- _classPrivateFieldSet(_tail, this, null);
3531
+ _classPrivateFieldSet$1(_tail, this, null);
3695
3532
  }
3696
- _classPrivateFieldSet(_size, this, (_this$size5 = _classPrivateFieldGet(_size, this), _this$size5--, _this$size5));
3533
+ _classPrivateFieldSet$1(_size, this, (_this$size5 = _classPrivateFieldGet$1(_size, this), _this$size5--, _this$size5));
3697
3534
  return value;
3698
3535
  }
3699
3536
 
@@ -3706,17 +3543,17 @@ var LinkedList = /*#__PURE__*/function () {
3706
3543
  key: "pop",
3707
3544
  value: function pop() {
3708
3545
  var _this$size7;
3709
- if (_classPrivateFieldGet(_tail, this) === null) {
3546
+ if (_classPrivateFieldGet$1(_tail, this) === null) {
3710
3547
  return undefined;
3711
3548
  }
3712
- var value = _classPrivateFieldGet(_tail, this).value;
3713
- _classPrivateFieldSet(_tail, this, _classPrivateFieldGet(_tail, this).previous);
3714
- if (_classPrivateFieldGet(_tail, this) !== null) {
3715
- _classPrivateFieldGet(_tail, this).next = null;
3549
+ var value = _classPrivateFieldGet$1(_tail, this).value;
3550
+ _classPrivateFieldSet$1(_tail, this, _classPrivateFieldGet$1(_tail, this).previous);
3551
+ if (_classPrivateFieldGet$1(_tail, this) !== null) {
3552
+ _classPrivateFieldGet$1(_tail, this).next = null;
3716
3553
  } else {
3717
- _classPrivateFieldSet(_head, this, null);
3554
+ _classPrivateFieldSet$1(_head, this, null);
3718
3555
  }
3719
- _classPrivateFieldSet(_size, this, (_this$size7 = _classPrivateFieldGet(_size, this), _this$size7--, _this$size7));
3556
+ _classPrivateFieldSet$1(_size, this, (_this$size7 = _classPrivateFieldGet$1(_size, this), _this$size7--, _this$size7));
3720
3557
  return value;
3721
3558
  }
3722
3559
  }]);
@@ -3749,5 +3586,256 @@ var SerializableMap = /*#__PURE__*/function (_Map) {
3749
3586
  }]);
3750
3587
  }(/*#__PURE__*/_wrapNativeSuper(Map));
3751
3588
 
3752
- export { ARRAY, FLOAT, FLOAT_ANY, FLOAT_LAX, FLOAT_LAX_ANY, INT, INT_ANY, INT_LAX, INT_LAX_ANY, ISSET, IS_ARRAY, IS_OBJECT, LeUtils, LinkedList, OBJECT, STRING, STRING_ANY, SerializableMap };
3589
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
3590
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3591
+ function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
3592
+ function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
3593
+ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
3594
+
3595
+ /**
3596
+ * A TreeSet is a set of elements, sorted by a comparator.
3597
+ * Binary search is used to find elements, which makes it very fast to find elements.
3598
+ *
3599
+ * The comparator is also used to determine if two values are equal to each other.
3600
+ * This way, you can have values that aren't the same be treated as if they are. This can be used to deal with issues such as floating point errors for example.
3601
+ */
3602
+ var _elements = /*#__PURE__*/new WeakMap();
3603
+ var _comparator = /*#__PURE__*/new WeakMap();
3604
+ var TreeSet = /*#__PURE__*/function () {
3605
+ /**
3606
+ * Creates a new TreeSet with the given elements and comparator.
3607
+ *
3608
+ * @param {*[]} [elements=[]] - The initial elements of the set.
3609
+ * @param {(valueA:*, valueB:*) => number} [comparator=LeUtils.compare] - The comparator function to use for sorting.
3610
+ */
3611
+ function TreeSet(elements, comparator) {
3612
+ _classCallCheck(this, TreeSet);
3613
+ /** @type {*[]} */
3614
+ _classPrivateFieldInitSpec(this, _elements, void 0);
3615
+ /** @type {(valueA:*, valueB:*) => number} */
3616
+ _classPrivateFieldInitSpec(this, _comparator, void 0);
3617
+ _classPrivateFieldSet(_comparator, this, comparator || LeUtils.compare);
3618
+ _classPrivateFieldSet(_elements, this, elements || []);
3619
+ _classPrivateFieldGet(_elements, this).sort(_classPrivateFieldGet(_comparator, this));
3620
+ }
3621
+
3622
+ /**
3623
+ *
3624
+ *
3625
+ * @param {*} value - The value to search for in the set.
3626
+ * @returns {{found:boolean, index:number, value:*|undefined}} - An object containing whether the value was found, the index where it would be inserted, and the value at that index (if found).
3627
+ * @private
3628
+ */
3629
+ return _createClass(TreeSet, [{
3630
+ key: "binarySearch",
3631
+ value: function binarySearch(value) {
3632
+ var low = 0;
3633
+ var high = _classPrivateFieldGet(_elements, this).length - 1;
3634
+ while (low <= high) {
3635
+ var mid = Math.floor((low + high) / 2);
3636
+ var midValue = _classPrivateFieldGet(_elements, this)[mid];
3637
+ var cmp = _classPrivateFieldGet(_comparator, this).call(this, midValue, value);
3638
+ if (cmp < 0) {
3639
+ low = mid + 1;
3640
+ } else if (cmp > 0) {
3641
+ high = mid - 1;
3642
+ } else {
3643
+ return {
3644
+ found: true,
3645
+ index: mid,
3646
+ value: midValue
3647
+ };
3648
+ }
3649
+ }
3650
+ return {
3651
+ found: false,
3652
+ index: low,
3653
+ value: undefined
3654
+ };
3655
+ }
3656
+ }, {
3657
+ key: "getElements",
3658
+ value:
3659
+ /**
3660
+ * Returns the elements of the set.
3661
+ */
3662
+ function getElements() {
3663
+ return _classPrivateFieldGet(_elements, this);
3664
+ }
3665
+
3666
+ /**
3667
+ * Returns the comparator of the set.
3668
+ *
3669
+ * @returns {(valueA:*, valueB:*) => number}
3670
+ */
3671
+ }, {
3672
+ key: "getComparator",
3673
+ value: function getComparator() {
3674
+ return _classPrivateFieldGet(_comparator, this);
3675
+ }
3676
+
3677
+ /**
3678
+ * Returns the size of the set.
3679
+ *
3680
+ * @returns {number}
3681
+ */
3682
+ }, {
3683
+ key: "size",
3684
+ value: function size() {
3685
+ return _classPrivateFieldGet(_elements, this).length;
3686
+ }
3687
+
3688
+ /**
3689
+ * Returns true if the set is empty, false otherwise.
3690
+ *
3691
+ * @returns {boolean}
3692
+ */
3693
+ }, {
3694
+ key: "isEmpty",
3695
+ value: function isEmpty() {
3696
+ return _classPrivateFieldGet(_elements, this).length <= 0;
3697
+ }
3698
+
3699
+ /**
3700
+ * Returns true if the set contains a value that is equal to the given value, returns false otherwise.
3701
+ *
3702
+ * @param {*} value - The value to check for in the set.
3703
+ * @return {boolean} - True if the set contains the value, false otherwise.
3704
+ */
3705
+ }, {
3706
+ key: "contains",
3707
+ value: function contains(value) {
3708
+ return this.binarySearch(value).found;
3709
+ }
3710
+
3711
+ /**
3712
+ * Returns the first element of the set, or undefined if it is empty.
3713
+ *
3714
+ * @return {*|undefined} - The first element of the set, or undefined if it is empty.
3715
+ */
3716
+ }, {
3717
+ key: "first",
3718
+ value: function first() {
3719
+ return _classPrivateFieldGet(_elements, this).length > 0 ? _classPrivateFieldGet(_elements, this)[0] : undefined;
3720
+ }
3721
+
3722
+ /**
3723
+ * Returns the last element of the set, or undefined if it is empty.
3724
+ *
3725
+ * @return {*|undefined} - The last element of the set, or undefined if it is empty.
3726
+ */
3727
+ }, {
3728
+ key: "last",
3729
+ value: function last() {
3730
+ return _classPrivateFieldGet(_elements, this).length > 0 ? _classPrivateFieldGet(_elements, this)[_classPrivateFieldGet(_elements, this).length - 1] : undefined;
3731
+ }
3732
+
3733
+ /**
3734
+ * Removes and returns the first element of the set, or undefined if it is empty.
3735
+ *
3736
+ * @returns {*|undefined} - The first element of the set, or undefined if it is empty.
3737
+ */
3738
+ }, {
3739
+ key: "pollFirst",
3740
+ value: function pollFirst() {
3741
+ return _classPrivateFieldGet(_elements, this).length > 0 ? _classPrivateFieldGet(_elements, this).splice(0, 1)[0] : undefined;
3742
+ }
3743
+
3744
+ /**
3745
+ * Removes and returns the last element of the set, or undefined if it is empty.
3746
+ *
3747
+ * @returns {*|undefined} - The last element of the set, or undefined if it is empty.
3748
+ */
3749
+ }, {
3750
+ key: "pollLast",
3751
+ value: function pollLast() {
3752
+ return _classPrivateFieldGet(_elements, this).length > 0 ? _classPrivateFieldGet(_elements, this).splice(_classPrivateFieldGet(_elements, this).length - 1, 1)[0] : undefined;
3753
+ }
3754
+
3755
+ /**
3756
+ * Adds the given value to the set. Will only do so if no equal value already exists.
3757
+ * @param {*} value - The value to add to the set.
3758
+ */
3759
+ }, {
3760
+ key: "add",
3761
+ value: function add(value) {
3762
+ var result = this.binarySearch(value);
3763
+ if (result.found) {
3764
+ return;
3765
+ }
3766
+ _classPrivateFieldGet(_elements, this).splice(result.index, 0, value);
3767
+ }
3768
+
3769
+ /**
3770
+ * Adds all the given values to the set. Will only do so if no equal value already exists.
3771
+ *
3772
+ * @param {*} values - The values to add to the set.
3773
+ */
3774
+ }, {
3775
+ key: "addAll",
3776
+ value: function addAll(values) {
3777
+ LeUtils.each(values, this.add.bind(this));
3778
+ }
3779
+
3780
+ /**
3781
+ * Returns an equal value that's already in the tree set, or undefined if no equal values in it exist.
3782
+ *
3783
+ * @param {*} value - The value to search for in the set.
3784
+ * @return {*|undefined} - The equal value if found, or undefined if not found.
3785
+ */
3786
+ }, {
3787
+ key: "getEqualValue",
3788
+ value: function getEqualValue(value) {
3789
+ var result = this.binarySearch(value);
3790
+ if (result.found) {
3791
+ return result.value;
3792
+ }
3793
+ return undefined;
3794
+ }
3795
+
3796
+ /**
3797
+ * Returns an equal value that's already in the tree set. If no equal values in it exist, the given value will be added and returned.
3798
+ *
3799
+ * @param {*} value - The value to search for in the set.
3800
+ * @return {*} - The equal value if found, or the added value if not found.
3801
+ */
3802
+ }, {
3803
+ key: "getEqualValueOrAdd",
3804
+ value: function getEqualValueOrAdd(value) {
3805
+ var result = this.binarySearch(value);
3806
+ if (result.found) {
3807
+ return result.value;
3808
+ }
3809
+ _classPrivateFieldGet(_elements, this).splice(result.index, 0, value);
3810
+ return value;
3811
+ }
3812
+
3813
+ /**
3814
+ * Returns a string representation of the TreeSet.
3815
+ *
3816
+ * @returns {string} - A string representation of the TreeSet, including its elements and comparator.
3817
+ */
3818
+ }, {
3819
+ key: "toString",
3820
+ value: function toString() {
3821
+ return "TreeSet{elements:".concat(_classPrivateFieldGet(_elements, this), ", comparator:").concat(_classPrivateFieldGet(_comparator, this), "}");
3822
+ }
3823
+
3824
+ /**
3825
+ * Returns a JSON representation of the TreeSet.
3826
+ *
3827
+ * @returns {Object} - An object containing the elements and comparator of the TreeSet.
3828
+ */
3829
+ }, {
3830
+ key: "toJSON",
3831
+ value: function toJSON() {
3832
+ return {
3833
+ elements: _classPrivateFieldGet(_elements, this),
3834
+ comparator: _classPrivateFieldGet(_comparator, this).toString()
3835
+ };
3836
+ }
3837
+ }]);
3838
+ }();
3839
+
3840
+ export { ARRAY, FLOAT, FLOAT_ANY, FLOAT_LAX, FLOAT_LAX_ANY, INT, INT_ANY, INT_LAX, INT_LAX_ANY, ISSET, IS_ARRAY, IS_OBJECT, LeUtils, LinkedList, OBJECT, STRING, STRING_ANY, SerializableMap, TreeSet };
3753
3841
  //# sourceMappingURL=index.js.map