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

What about TypedArray views?

Open ghost opened this issue 7 years ago • 6 comments
trafficstars

The rationale would seem to apply equally to them.

ghost avatar Mar 29 '18 16:03 ghost

Good point; anything that is added here to Array.prototype should probably be added to TypedArray.prototype.

ljharb avatar Mar 30 '18 07:03 ljharb

PRs always welcome 👍

keithamus avatar Apr 03 '18 08:04 keithamus

2 questions: should proposed accessors validate that the target is a typed array and what the behaviour expected for typed arrays with zero length?

zloirock avatar Apr 03 '18 20:04 zloirock

@zloirock Is there any reason to do it differently than for Arrays? As far as I can tell, the proposed spec would work for typed arrays without changes… right?

addaleax avatar Apr 03 '18 20:04 addaleax

@addaleax almost all typed array methods are non-generic and throws an error on something different from typed array. Typed arrays have a constant length, so setting .lastItem for typed arrays with zero length by the current spec is an error.

zloirock avatar Apr 03 '18 20:04 zloirock

If the issue @zloirock brought up is resolved, I can look into submitting a PR to add .lastItem and .lastIndex for TypedArrays.

jhpratt avatar Jul 12 '19 05:07 jhpratt