@creejs/commons-lang 2.1.33 → 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.
@@ -2834,6 +2834,26 @@ function chunk (array, size) {
2834
2834
  return chunked
2835
2835
  }
2836
2836
 
2837
+ // owned
2838
+ /**
2839
+ * @template T
2840
+ * @param {Iterator<T>} iterator
2841
+ * @param {number} howMany
2842
+ * @returns {Array<T>}
2843
+ */
2844
+ function take$1 (iterator, howMany) {
2845
+ const rtnVal = [];
2846
+ let next;
2847
+ for (let i = 0; i < howMany && !(next = iterator.next()).done; i++) {
2848
+ rtnVal.push(next.value);
2849
+ }
2850
+ return rtnVal
2851
+ }
2852
+
2853
+ var IteratorUtils = {
2854
+ take: take$1
2855
+ };
2856
+
2837
2857
  // owned
2838
2858
 
2839
2859
  /**
@@ -2845,13 +2865,10 @@ function chunk (array, size) {
2845
2865
  function length (iterable) {
2846
2866
  TypeAssert.assertIterable(iterable);
2847
2867
  // @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
2868
+ const length = iterable.length ?? iterable.size;
2869
+ // @ts-ignore
2870
+ if (typeof length === 'number') {
2871
+ return length
2855
2872
  }
2856
2873
  let counter = 0;
2857
2874
  // eslint-disable-next-line no-unused-vars
@@ -2861,8 +2878,28 @@ function length (iterable) {
2861
2878
  return counter
2862
2879
  }
2863
2880
 
2864
- var IteratorUtils = {
2865
- length
2881
+ /**
2882
+ * @template T
2883
+ * @param {Iterable<T>} iterable
2884
+ * @param {number} howMany
2885
+ * @returns {Array<T>}
2886
+ */
2887
+ function take (iterable, howMany) {
2888
+ // if (length(iterable) <= howMany) {
2889
+ // return [...iterable]
2890
+ // }
2891
+ const iterator = iterable[Symbol.iterator]();
2892
+ const rtnVal = [];
2893
+ let next;
2894
+ for (let i = 0; i < howMany && !(next = iterator.next()).done; i++) {
2895
+ rtnVal.push(next.value);
2896
+ }
2897
+ return rtnVal
2898
+ }
2899
+
2900
+ var IterableUtils = {
2901
+ length,
2902
+ take
2866
2903
  };
2867
2904
 
2868
2905
  /**
@@ -2889,8 +2926,9 @@ var index = {
2889
2926
  ArrayBufferUtils,
2890
2927
  TimeUtils,
2891
2928
  ArrayUtils,
2892
- IteratorUtils
2929
+ IteratorUtils,
2930
+ IterableUtils
2893
2931
  };
2894
2932
 
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 };
2933
+ export { AggregatedError, ArrayBufferUtils, ArrayUtils, ClassProxyUtils, ExecUtils as Exec, ExecUtils, InstanceProxyUtils, IterableUtils, IteratorUtils, LangUtils as Lang, LangUtils, PromiseUtils, ReflectUtils, StringUtils, TimeUtils, TypeUtils as Type, TypeAssert, TypeUtils, TypedArrayUtils, _Error, index as default };
2896
2934
  //# sourceMappingURL=index-dev.js.map