Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper functions on %RangeIteratorPrototype% #12

Closed
Jack-Works opened this issue Feb 13, 2020 · 6 comments
Closed

Add helper functions on %RangeIteratorPrototype% #12

Jack-Works opened this issue Feb 13, 2020 · 6 comments

Comments

@Jack-Works
Copy link
Member

Jack-Works commented Feb 13, 2020

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

@chicoxyzzy
Copy link
Member

chicoxyzzy commented Mar 3, 2020

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?

@Jack-Works
Copy link
Member Author

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

@chicoxyzzy
Copy link
Member

Some possible instance and static methods:

  • Number.Range.isFinite()
  • Number.Range.prototype.toLocaleString([locales [, options]])
  • BigInt.Range.prototype.toLocaleString([locales [, options]])

@Jack-Works
Copy link
Member Author

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().

@Jack-Works
Copy link
Member Author

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.

@Jack-Works Jack-Works changed the title Return a Range object instead? Add helper functions on %RangeIteratorPrototype% Mar 5, 2020
@Jack-Works
Copy link
Member Author

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.

@tc39 tc39 locked as resolved and limited conversation to collaborators Jun 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants