-
Notifications
You must be signed in to change notification settings - Fork 30
Allow converting List<int>
to a JSArray
/ JSTypedArray
#91
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
a) This one is complex and we've discussed it several times. We can definitely do the simple route of exposing an extension member that would be essentially the code you wrote above. The semantics there are consistent across all backends. It's a bit more complicated if we want to take advantage of the type representation for performance benefits on the JS backends. On the JS backends, a Note that while If we were to add this extension method, I propose we do the consistent semantics. b) The IDL defines We could instead generate cc @sigmundch |
cc @rakudrama For (b), I wonder if we should be exposing something like For (a) - a lot of our concerns with the |
The var a = new Blob(new Int32Array(3)); // Blob {size: 3}
var b = new Blob([new Int32Array(3)]); // Blob {size: 12}
So... I think it is a bad idea to enabling the |
Note @rakudrama that this is referring to the Blob API in Line 17 in e0564a4
So the request is whether we can provide a zero-cost conversion between |
You mean as the representation type for the JS type interface? I think that would only work if we have an interceptor for every possible indexable JS type. I was imagining it to be
That's...pretty confusing. I'm torn because while it is confusing, it's also what the API allows you to do. |
Currently, there is no easy way to pass a
List<int>/Uint8List
to theBlob
constructor.We have to do stuff like:
Per https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob#array the constructor's field for the array supports
TypedArray
.There is also no extension to convert a
List<int>
(which Uint8List implements) to aJSArray
, since we only have that forList<JSAny?>
. Butint
is a primitive that is allowed.I propose we do either of (or both?)
a) add an extension that converts a
List<int>
to a JSArrayb) update the Blob constructor to also allow a
JSTypedArray
Personally I would just add option a, since it is easy and we don't need to change the Blob constructor.Context: flutter/flutter#137374
The text was updated successfully, but these errors were encountered: