Closed jakearchibald closed 3 years ago
Async iterators can take arguments! So there's no need for matchAll()
; you can just use self.systemFonts[Symbol.asyncIterator]({ name: 'foo' })
, or self.systemFonts.values({ name: 'foo' })
. This is done in IDL by using the syntax
async iterable<value_type>(optional SomeOptionsDict options = {});
For specifying this, see https://streams.spec.whatwg.org/#rs-asynciterator plus the IDL block at https://streams.spec.whatwg.org/#rs-class-definition for an example.
Ohhh, self.systemFonts.values({ name: 'foo' })
provides the ergonomics I was looking for. I felt self.systemFonts[Symbol.asyncIterator]({ name: 'foo' })
was too ugly.
Sorry @domenic, I think I need your help on this one.
If we were to solve https://github.com/WICG/local-font-access/issues/27, I'd go for an API like:
In this case:
…is an alias of:
But
matchAll
provides the ability to query:You could also do:
…but I think it's worth providing the named method for ergonomics.
However, I can't see a way in IDL to declare a method that returns an async iterator like this. I guess I could call the
@@asynciterator
directly, but that seems not-how-we-usually-do-things.