├── .npmrc ├── .github └── workflows │ ├── build.yml │ └── deploy.yml ├── package.json ├── .gitignore ├── LICENSE ├── spec.emu └── README.md /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build spec 2 | 3 | on: [pull_request, push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: ljharb/actions/node/install@main 12 | name: 'nvm install lts/* && npm install' 13 | with: 14 | node-version: lts/* 15 | - run: npm run build 16 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy gh-pages 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: ljharb/actions/node/install@main 15 | name: 'nvm install lts/* && npm install' 16 | with: 17 | node-version: lts/* 18 | - run: npm run build 19 | - uses: JamesIves/github-pages-deploy-action@v4.3.3 20 | with: 21 | branch: gh-pages 22 | folder: build 23 | clean: true 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "template-for-proposals", 4 | "description": "A repository template for ECMAScript proposals.", 5 | "scripts": { 6 | "start": "npm run build-loose -- --watch", 7 | "build": "npm run build-loose -- --strict", 8 | "build-loose": "node -e 'fs.mkdirSync(\"build\", { recursive: true })' && ecmarkup --load-biblio @tc39/ecma262-biblio --verbose spec.emu build/index.html --lint-spec" 9 | }, 10 | "homepage": "https://github.com/tc39/template-for-proposals#readme", 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/tc39/template-for-proposals.git" 14 | }, 15 | "license": "MIT", 16 | "devDependencies": { 17 | "@tc39/ecma262-biblio": "^2.1.2778", 18 | "ecmarkup": "^20.0.0" 19 | }, 20 | "engines": { 21 | "node": ">= 12" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | 39 | # Only apps should have lockfiles 40 | yarn.lock 41 | package-lock.json 42 | npm-shrinkwrap.json 43 | pnpm-lock.yaml 44 | 45 | # Build directory 46 | build 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 ECMA TC39 and contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /spec.emu: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
 7 | title: DataView get/set Uint8Clamped methods
 8 | stage: 1
 9 | contributors: Jordan Harband
10 | 
11 | 12 | 13 |

Structured Data

14 | 15 | 16 |

DataView Objects

17 | 18 | 19 |

Properties of the DataView Prototype Object

20 | 21 | 22 |

DataView.prototype.getUint8Clamped ( _byteOffset_ )

23 |

This method performs the following steps when called:

24 | 25 | 1. Let _v_ be the *this* value. 26 | 1. Return ? GetViewValue(_v_, _byteOffset_, *true*, ~uint8clamped~). 27 | 28 |
29 | 30 | 31 |

DataView.prototype.setUint8Clamped ( _byteOffset_, _value_ )

32 |

This method performs the following steps when called:

33 | 34 | 1. Let _v_ be the *this* value. 35 | 1. Return ? SetViewValue(_v_, _byteOffset_, *true*, ~uint8clamped~, _value_). 36 | 37 |
38 |
39 |
40 |
41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DataView get/set Uint8Clamped methods 2 | 3 | There are currently 11 kinds of Typed Array in the language. 4 | 5 | Stage: 1 6 | 7 | ## Motivation/Use Case 8 | 9 | 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. 10 | 11 | ## Problem 12 | Only 10 of them have DataView get/set methods. 13 | 14 | Here's a matrix representing the consistently available functionality for each of them: 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 |
Nameconstructorshared prototypeArrayBuffersDataView get methodDataView set method
Int8Array:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
Uint8Array:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
Uint8ClampedArray:white_check_mark::white_check_mark::white_check_mark::x::x:
Int16Array:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
Uint16Array:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
Int32Array:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
Uint32Array:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
BigInt64Array:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
BigUint64Array:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
Float32Array:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
Float64Array:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:
118 | 119 | ## Solution 120 | 121 | Add the get and set methods to round out Typed Array support. 122 | 123 | ## Use Cases 124 | - dynamic dispatch based on Typed Array type: https://github.com/esfx/esfx/blob/main/packages/struct-type/src/internal/numbers.ts#L122-L133 --------------------------------------------------------------------------------