@creejs/commons-lang 2.1.31 → 2.1.32

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.
@@ -791,7 +791,8 @@
791
791
  assertBigInt64Array,
792
792
  assertBigUint64Array,
793
793
  assertTypedArray,
794
- assertArrayBuffer
794
+ assertArrayBuffer,
795
+ assertIterable
795
796
  };
796
797
  /**
797
798
  * if value is not Array, throw error
@@ -1157,6 +1158,18 @@
1157
1158
  }
1158
1159
  }
1159
1160
 
1161
+ /**
1162
+ * Asserts that the given value is Iterable
1163
+ * @param {*} value - The value to check.
1164
+ * @param {string} [paramName] - Optional parameter name for error message.
1165
+ * @throws {Error} Throws an error if the value is not Iterable
1166
+ */
1167
+ function assertIterable (value, paramName) {
1168
+ if (!isIterable(value)) {
1169
+ throw new Error(`${paramName ? '"' + paramName + '" ' : ''}Not Iterable`)
1170
+ }
1171
+ }
1172
+
1160
1173
  // 3rd
1161
1174
  // internal
1162
1175
  // owned
@@ -2827,6 +2840,35 @@
2827
2840
  return chunked
2828
2841
  }
2829
2842
 
2843
+ // owned
2844
+
2845
+ /**
2846
+ * @template T
2847
+ * @param {Iterable<T>} iterable
2848
+ */
2849
+ function length (iterable) {
2850
+ TypeAssert.assertIterable(iterable);
2851
+ // @ts-ignore
2852
+ if (typeof iterable.length !== 'undefined') {
2853
+ // @ts-ignore
2854
+ return iterable.length
2855
+ // @ts-ignore
2856
+ } else if (typeof iterable.size !== 'undefined') {
2857
+ // @ts-ignore
2858
+ return iterable.size
2859
+ }
2860
+ let counter = 0;
2861
+ // eslint-disable-next-line no-unused-vars
2862
+ for (const _item of iterable) {
2863
+ counter++;
2864
+ }
2865
+ return counter
2866
+ }
2867
+
2868
+ var IteratorUtils = {
2869
+ length
2870
+ };
2871
+
2830
2872
  /**
2831
2873
  * @module Lang
2832
2874
  * @description Core language utilities for type checking, string manipulation, and common operations.
@@ -2850,7 +2892,8 @@
2850
2892
  TypedArrayUtils,
2851
2893
  ArrayBufferUtils,
2852
2894
  TimeUtils,
2853
- ArrayUtils
2895
+ ArrayUtils,
2896
+ IteratorUtils
2854
2897
  };
2855
2898
 
2856
2899
  exports.AggregatedError = AggregatedError;
@@ -2860,6 +2903,7 @@
2860
2903
  exports.Exec = ExecUtils;
2861
2904
  exports.ExecUtils = ExecUtils;
2862
2905
  exports.InstanceProxyUtils = InstanceProxyUtils;
2906
+ exports.IteratorUtils = IteratorUtils;
2863
2907
  exports.Lang = LangUtils;
2864
2908
  exports.LangUtils = LangUtils;
2865
2909
  exports.PromiseUtils = PromiseUtils;