@creejs/commons-lang 2.1.33 → 2.1.34

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.
@@ -2839,34 +2839,23 @@ function chunk (array, size) {
2839
2839
  }
2840
2840
 
2841
2841
  // owned
2842
-
2843
2842
  /**
2844
2843
  * @template T
2845
- * @param {Iterable<T>} iterable
2846
- * @returns {number}
2847
- * @throws {Error} Not Iterable
2844
+ * @param {Iterator<T>} iterator
2845
+ * @param {number} howMany
2846
+ * @returns {Array<T>}
2848
2847
  */
2849
- function length (iterable) {
2850
- TypeAssert.assertIterable(iterable);
2851
- // @ts-ignore
2852
- if (typeof iterable.length !== 'undefined') {
2853
- // @ts-ignore
2854
- return iterable.length
2855
- // @ts-ignore
2856
- } else if (typeof iterable.size !== 'undefined') {
2857
- // @ts-ignore
2858
- return iterable.size
2859
- }
2860
- let counter = 0;
2861
- // eslint-disable-next-line no-unused-vars
2862
- for (const _item of iterable) {
2863
- counter++;
2848
+ function take (iterator, howMany) {
2849
+ const rtnVal = [];
2850
+ let next;
2851
+ for (let i = 0; i < howMany && !(next = iterator.next()).done; i++) {
2852
+ rtnVal.push(next.value);
2864
2853
  }
2865
- return counter
2854
+ return rtnVal
2866
2855
  }
2867
2856
 
2868
2857
  var IteratorUtils = {
2869
- length
2858
+ take
2870
2859
  };
2871
2860
 
2872
2861
  /**