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