@creejs/commons-lang 2.1.31 → 2.1.33

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,37 @@ 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
+ * @returns {number}
2843
+ * @throws {Error} Not Iterable
2844
+ */
2845
+ function length (iterable) {
2846
+ TypeAssert.assertIterable(iterable);
2847
+ // @ts-ignore
2848
+ if (typeof iterable.length !== 'undefined') {
2849
+ // @ts-ignore
2850
+ return iterable.length
2851
+ // @ts-ignore
2852
+ } else if (typeof iterable.size !== 'undefined') {
2853
+ // @ts-ignore
2854
+ return iterable.size
2855
+ }
2856
+ let counter = 0;
2857
+ // eslint-disable-next-line no-unused-vars
2858
+ for (const _item of iterable) {
2859
+ counter++;
2860
+ }
2861
+ return counter
2862
+ }
2863
+
2864
+ var IteratorUtils = {
2865
+ length
2866
+ };
2867
+
2824
2868
  /**
2825
2869
  * @module Lang
2826
2870
  * @description Core language utilities for type checking, string manipulation, and common operations.
@@ -2844,8 +2888,9 @@ var index = {
2844
2888
  TypedArrayUtils,
2845
2889
  ArrayBufferUtils,
2846
2890
  TimeUtils,
2847
- ArrayUtils
2891
+ ArrayUtils,
2892
+ IteratorUtils
2848
2893
  };
2849
2894
 
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 };
2895
+ 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
2896
  //# sourceMappingURL=index-dev.js.map