@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.
@@ -785,7 +785,8 @@ var TypeAssert = {
785
785
  assertBigInt64Array,
786
786
  assertBigUint64Array,
787
787
  assertTypedArray,
788
- assertArrayBuffer
788
+ assertArrayBuffer,
789
+ assertIterable
789
790
  };
790
791
  /**
791
792
  * if value is not Array, throw error
@@ -1151,6 +1152,18 @@ function assertArrayBuffer (value, paramName) {
1151
1152
  }
1152
1153
  }
1153
1154
 
1155
+ /**
1156
+ * Asserts that the given value is Iterable
1157
+ * @param {*} value - The value to check.
1158
+ * @param {string} [paramName] - Optional parameter name for error message.
1159
+ * @throws {Error} Throws an error if the value is not Iterable
1160
+ */
1161
+ function assertIterable (value, paramName) {
1162
+ if (!isIterable(value)) {
1163
+ throw new Error(`${paramName ? '"' + paramName + '" ' : ''}Not Iterable`)
1164
+ }
1165
+ }
1166
+
1154
1167
  // 3rd
1155
1168
  // internal
1156
1169
  // owned
@@ -2821,6 +2834,35 @@ function chunk (array, size) {
2821
2834
  return chunked
2822
2835
  }
2823
2836
 
2837
+ // owned
2838
+
2839
+ /**
2840
+ * @template T
2841
+ * @param {Iterable<T>} iterable
2842
+ */
2843
+ function length (iterable) {
2844
+ TypeAssert.assertIterable(iterable);
2845
+ // @ts-ignore
2846
+ if (typeof iterable.length !== 'undefined') {
2847
+ // @ts-ignore
2848
+ return iterable.length
2849
+ // @ts-ignore
2850
+ } else if (typeof iterable.size !== 'undefined') {
2851
+ // @ts-ignore
2852
+ return iterable.size
2853
+ }
2854
+ let counter = 0;
2855
+ // eslint-disable-next-line no-unused-vars
2856
+ for (const _item of iterable) {
2857
+ counter++;
2858
+ }
2859
+ return counter
2860
+ }
2861
+
2862
+ var IteratorUtils = {
2863
+ length
2864
+ };
2865
+
2824
2866
  /**
2825
2867
  * @module Lang
2826
2868
  * @description Core language utilities for type checking, string manipulation, and common operations.
@@ -2844,8 +2886,9 @@ var index = {
2844
2886
  TypedArrayUtils,
2845
2887
  ArrayBufferUtils,
2846
2888
  TimeUtils,
2847
- ArrayUtils
2889
+ ArrayUtils,
2890
+ IteratorUtils
2848
2891
  };
2849
2892
 
2850
- export { AggregatedError, ArrayBufferUtils, ArrayUtils, ClassProxyUtils, ExecUtils as Exec, ExecUtils, InstanceProxyUtils, LangUtils as Lang, LangUtils, PromiseUtils, ReflectUtils, StringUtils, TimeUtils, TypeUtils as Type, TypeAssert, TypeUtils, TypedArrayUtils, _Error, index as default };
2893
+ export { AggregatedError, ArrayBufferUtils, ArrayUtils, ClassProxyUtils, ExecUtils as Exec, ExecUtils, InstanceProxyUtils, IteratorUtils, LangUtils as Lang, LangUtils, PromiseUtils, ReflectUtils, StringUtils, TimeUtils, TypeUtils as Type, TypeAssert, TypeUtils, TypedArrayUtils, _Error, index as default };
2851
2894
  //# sourceMappingURL=index-dev.js.map