tc39 / proposal-iterator.range

A proposal for ECMAScript to add a built-in Iterator.range()
https://tc39.es/proposal-iterator.range/
MIT License
487 stars 13 forks source link

Normative: Add a new overload to make reuse easier. #47

Closed Jack-Works closed 3 years ago

Jack-Works commented 3 years ago

A new overload:

 type RangeFunction<T extends number | bigint> = {
+    range(option: { start: T; end: T | Infinity; step?: T; inclusive?: boolean }): RangeIterator<T>
     range(start: T, end: T | Infinity, option?: T | { step?: T; inclusive?: boolean }): RangeIterator<T>
     range(start: T, end: T | Infinity, step?: T): RangeIterator<T>
 }

This will allow the following pattern to make the reuse easier:

const x = Number.range(0, 2)
consume_iterator(x)
const y = Number.range(x) // a fresh iterator
codecov-io commented 3 years ago

Codecov Report

Merging #47 (c8cd170) into master (f5404e8) will increase coverage by 0.07%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #47      +/-   ##
==========================================
+ Coverage   99.37%   99.44%   +0.07%     
==========================================
  Files           1        1              
  Lines         160      181      +21     
  Branches       50       55       +5     
==========================================
+ Hits          159      180      +21     
  Misses          1        1              
Impacted Files Coverage Δ
polyfill.js 99.44% <100.00%> (+0.07%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f5404e8...c8cd170. Read the comment docs.