proposal-array-filtering icon indicating copy to clipboard operation
proposal-array-filtering copied to clipboard

%TypedArray% methods

Open zloirock opened this issue 4 years ago • 3 comments

Sure, methods from this proposal should have equal on %TypedArray%.

The question: how should work %TypedArray%.prototype.groupBy?

zloirock avatar Jul 14 '21 09:07 zloirock

Sure, methods from this proposal should have equal on %TypedArray%.

Yup. Strangely flatMap is also missing, though flat would obviously not do anything.

The question: how should work %TypedArray%.prototype.groupBy?

I think what you're hinting at is what the values would be in the return object? In a normal array.groupBy(), we'd receive { [key: string]: T[] } (arrays of the items). We might want to return the TypedArray and populate it with the items instead of a plain array?

jridgewell avatar Jul 14 '21 18:07 jridgewell

I mean that since the length of typed arrays is a constant, we can't use the same logic for returning object with typed arrays.

zloirock avatar Jul 14 '21 18:07 zloirock

we can't use the same logic for returning object with typed arrays

Correct, but the spec text can change to support it. I wrote the spec the way I would write the JS, but it may be more appropriate to use a list of { key, list } structs internally, and transform that into the output object and array/typedarray.

jridgewell avatar Jul 14 '21 19:07 jridgewell