Closed Jack-Works closed 4 years ago
Does that also means introducing new Range
type with possible static methods on it? Should two new types Number.Range
and Bigint.Range
be presented then?
yes, I think it will be useful but I'm not quite clear about what will the API looks like maybe some investigation on other languages
Some possible instance and static methods:
Number.Range.isFinite()
Number.Range.prototype.toLocaleString([locales [, options]])
BigInt.Range.prototype.toLocaleString([locales [, options]])
Maybe not making a Range object, but add useful methods on %RangeIteratorPrototype%
.
There're complains that said Number.range
is too long, and make Range a class will even longer ((new Number.range()).includes()
)
By adding methods on the %RangeIteratorPrototype%
, we can use it like Number.range(a, b).isFinite()
.
For the convenience of future polyfill, IMO it should also expose 3 getters (or non-writable values) start
, end
and step
to expose its internal slot.
Yes, we're going to have helper methods. I'm closing this issue. If anyone wants to suggest any helpers, please open a new issue. That will make the discussion easier to track.
Return a Range object with a @@iterator or extends %RangeIteratorPrototype% so we can add some helper functions on the range object like range.includes()
Possible methods on the Range object
includes(x)
@@iterator
@@slice
(https://github.com/tc39/proposal-slice-notation/issues/19 )toLocaleString(...)
(https://github.com/Jack-Works/proposal-Number.range/issues/12#issuecomment-593772905)readonly start
readonly end
readonly step
(For polyfill authors, https://github.com/Jack-Works/proposal-Number.range/issues/12#issuecomment-595006913 )