@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.
@@ -2841,7 +2841,7 @@ function chunk (array, size) {
2841
2841
  * @param {number} howMany
2842
2842
  * @returns {Array<T>}
2843
2843
  */
2844
- function take (iterator, howMany) {
2844
+ function take$1 (iterator, howMany) {
2845
2845
  const rtnVal = [];
2846
2846
  let next;
2847
2847
  for (let i = 0; i < howMany && !(next = iterator.next()).done; i++) {
@@ -2851,6 +2851,54 @@ function take (iterator, howMany) {
2851
2851
  }
2852
2852
 
2853
2853
  var IteratorUtils = {
2854
+ take: take$1
2855
+ };
2856
+
2857
+ // owned
2858
+
2859
+ /**
2860
+ * @template T
2861
+ * @param {Iterable<T>} iterable
2862
+ * @returns {number}
2863
+ * @throws {Error} Not Iterable
2864
+ */
2865
+ function length (iterable) {
2866
+ TypeAssert.assertIterable(iterable);
2867
+ // @ts-ignore
2868
+ const length = iterable.length ?? iterable.size;
2869
+ // @ts-ignore
2870
+ if (typeof length === 'number') {
2871
+ return length
2872
+ }
2873
+ let counter = 0;
2874
+ // eslint-disable-next-line no-unused-vars
2875
+ for (const _item of iterable) {
2876
+ counter++;
2877
+ }
2878
+ return counter
2879
+ }
2880
+
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,
2854
2902
  take
2855
2903
  };
2856
2904
 
@@ -2878,8 +2926,9 @@ var index = {
2878
2926
  ArrayBufferUtils,
2879
2927
  TimeUtils,
2880
2928
  ArrayUtils,
2881
- IteratorUtils
2929
+ IteratorUtils,
2930
+ IterableUtils
2882
2931
  };
2883
2932
 
2884
- 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 };
2885
2934
  //# sourceMappingURL=index-dev.js.map