tc39 / proposal-dataview-get-set-uint8clamped

TC39 proposal to add DataView.prototype.getUint8Clamped and DataView.prototype.setUint8Clamped

Home Page:https://ljharb.github.io/proposal-dataview-get-set-uint8c/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DataView get/set Uint8Clamped methods

There are currently 11 kinds of Typed Array in the language.

Stage: 1

Motivation/Use Case

I'd like to dynamically dispatch to DataView methods based on the "type" of the Typed Array. This works great for all of the types except Uint8Clamped.

Problem

Only 10 of them have DataView get/set methods.

Here's a matrix representing the consistently available functionality for each of them:

Name constructor shared prototype ArrayBuffers DataView get method DataView set method
Int8Array
Uint8Array
Uint8ClampedArray
Int16Array
Uint16Array
Int32Array
Uint32Array
BigInt64Array
BigUint64Array
Float32Array
Float64Array

Solution

Add the get and set methods to round out Typed Array support.

About

TC39 proposal to add DataView.prototype.getUint8Clamped and DataView.prototype.setUint8Clamped

https://ljharb.github.io/proposal-dataview-get-set-uint8c/

License:MIT License