@creejs/commons-lang 2.1.34 → 2.1.35

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.
@@ -2847,7 +2847,7 @@
2847
2847
  * @param {number} howMany
2848
2848
  * @returns {Array<T>}
2849
2849
  */
2850
- function take (iterator, howMany) {
2850
+ function take$1 (iterator, howMany) {
2851
2851
  const rtnVal = [];
2852
2852
  let next;
2853
2853
  for (let i = 0; i < howMany && !(next = iterator.next()).done; i++) {
@@ -2857,6 +2857,54 @@
2857
2857
  }
2858
2858
 
2859
2859
  var IteratorUtils = {
2860
+ take: take$1
2861
+ };
2862
+
2863
+ // owned
2864
+
2865
+ /**
2866
+ * @template T
2867
+ * @param {Iterable<T>} iterable
2868
+ * @returns {number}
2869
+ * @throws {Error} Not Iterable
2870
+ */
2871
+ function length (iterable) {
2872
+ TypeAssert.assertIterable(iterable);
2873
+ // @ts-ignore
2874
+ const length = iterable.length ?? iterable.size;
2875
+ // @ts-ignore
2876
+ if (typeof length === 'number') {
2877
+ return length
2878
+ }
2879
+ let counter = 0;
2880
+ // eslint-disable-next-line no-unused-vars
2881
+ for (const _item of iterable) {
2882
+ counter++;
2883
+ }
2884
+ return counter
2885
+ }
2886
+
2887
+ /**
2888
+ * @template T
2889
+ * @param {Iterable<T>} iterable
2890
+ * @param {number} howMany
2891
+ * @returns {Array<T>}
2892
+ */
2893
+ function take (iterable, howMany) {
2894
+ // if (length(iterable) <= howMany) {
2895
+ // return [...iterable]
2896
+ // }
2897
+ const iterator = iterable[Symbol.iterator]();
2898
+ const rtnVal = [];
2899
+ let next;
2900
+ for (let i = 0; i < howMany && !(next = iterator.next()).done; i++) {
2901
+ rtnVal.push(next.value);
2902
+ }
2903
+ return rtnVal
2904
+ }
2905
+
2906
+ var IterableUtils = {
2907
+ length,
2860
2908
  take
2861
2909
  };
2862
2910
 
@@ -2884,7 +2932,8 @@
2884
2932
  ArrayBufferUtils,
2885
2933
  TimeUtils,
2886
2934
  ArrayUtils,
2887
- IteratorUtils
2935
+ IteratorUtils,
2936
+ IterableUtils
2888
2937
  };
2889
2938
 
2890
2939
  exports.AggregatedError = AggregatedError;
@@ -2894,6 +2943,7 @@
2894
2943
  exports.Exec = ExecUtils;
2895
2944
  exports.ExecUtils = ExecUtils;
2896
2945
  exports.InstanceProxyUtils = InstanceProxyUtils;
2946
+ exports.IterableUtils = IterableUtils;
2897
2947
  exports.IteratorUtils = IteratorUtils;
2898
2948
  exports.Lang = LangUtils;
2899
2949
  exports.LangUtils = LangUtils;