@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.
@@ -2835,34 +2835,23 @@ function chunk (array, size) {
2835
2835
  }
2836
2836
 
2837
2837
  // owned
2838
-
2839
2838
  /**
2840
2839
  * @template T
2841
- * @param {Iterable<T>} iterable
2842
- * @returns {number}
2843
- * @throws {Error} Not Iterable
2840
+ * @param {Iterator<T>} iterator
2841
+ * @param {number} howMany
2842
+ * @returns {Array<T>}
2844
2843
  */
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++;
2844
+ function take (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);
2860
2849
  }
2861
- return counter
2850
+ return rtnVal
2862
2851
  }
2863
2852
 
2864
2853
  var IteratorUtils = {
2865
- length
2854
+ take
2866
2855
  };
2867
2856
 
2868
2857
  /**