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