diff --git a/CHANGELOG.md b/CHANGELOG.md index f033861b94b4..54ca4caee27f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,11 @@ - `Math.clamp` - Moved to stage 2, [May 2025 TC39 meeting](https://github.com/tc39/proposal-math-clamp/commit/a005f28a6a03e175b9671de1c8c70dd5b7b08c2d) - Removed a `RangeError` if `min <= max` or `+0` min and `-0` max, [tc39/proposal-math-clamp/#22](https://github.com/tc39/proposal-math-clamp/issues/22) +- [`DataView` get / set `Uint8Clamped` methods proposal](https://github.com/tc39/proposal-dataview-get-set-uint8clamped): + - Methods: + - `DataView.prototype.getUint8Clamped` + - `DataView.prototype.setUint8Clamped` + - Moved to stage 2, October 2024 TC39 meeting - Always check regular expression flags by `flags` getter [PR](https://github.com/tc39/ecma262/pull/2791). Native methods are not fixed, only own implementation updated for: - `RegExp.prototype[@@match]` - `RegExp.prototype[@@replace]` diff --git a/README.md b/README.md index f309654aeba6..07c5f2ec8f3d 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,7 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) - [`AsyncIterator` helpers](#asynciterator-helpers) - [`Iterator.range`](#iteratorrange) - [`Array.isTemplateObject`](#arrayistemplateobject) + - [`DataView` get / set `Uint8Clamped` methods](#dataview-get-set-iint8clamped-methods) - [`Math.clamp`](#mathclamp) - [`String.dedent`](#stringdedent) - [`Symbol` predicates](#symbol-predicates) @@ -188,7 +189,6 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) - [`compositeKey` and `compositeSymbol`](#compositekey-and-compositesymbol) - [`Array` filtering](#array-filtering) - [`Array` deduplication](#array-deduplication) - - [`DataView` get / set `Uint8Clamped` methods](#dataview-get-set-iint8clamped-methods) - [`Number.fromString`](#numberfromstring) - [`String.cooked`](#stringcooked) - [`String.prototype.codePoints`](#stringprototypecodepoints) @@ -2978,6 +2978,27 @@ core-js(-pure)/full/array/is-template-object console.log(Array.isTemplateObject((it => it)`qwe${ 123 }asd`)); // => true ``` +##### [`DataView` get / set `Uint8Clamped` methods](https://github.com/tc39/proposal-dataview-get-set-uint8clamped)[⬆](#index) +Modules [`esnext.data-view.get-uint8-clamped`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js) and [`esnext.data-view.set-uint8-clamped`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js) +```ts +class DataView { + getUint8Clamped(offset: any): uint8 + setUint8Clamped(offset: any, value: any): void; +} +``` +[*CommonJS entry points:*](#commonjs-api) +``` +core-js/proposals/data-view-get-set-uint8-clamped +core-js/full/dataview/get-uint8-clamped +core-js/full/dataview/set-uint8-clamped +``` +[Examples](https://tinyurl.com/2h4zv8sw): +```js +const view = new DataView(new ArrayBuffer(1)); +view.setUint8Clamped(0, 100500); +console.log(view.getUint8Clamped(0)); // => 255 +``` + ##### [`Math.clamp`](https://github.com/tc39/proposal-math-clamp)[⬆](#index) Module [`esnext.math.clamp`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.math.clamp.js) ```ts @@ -3280,27 +3301,6 @@ core-js/full/typed-array/unique-by ].uniqueBy(it => it.uid); // => [{ id: 1, uid: 10000 }, { id: 3, uid: 10001 }] ``` -##### [`DataView` get / set `Uint8Clamped` methods](https://github.com/tc39/proposal-dataview-get-set-uint8clamped)[⬆](#index) -Modules [`esnext.data-view.get-uint8-clamped`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.data-view.get-uint8-clamped.js) and [`esnext.data-view.set-uint8-clamped`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js) -```ts -class DataView { - getUint8Clamped(offset: any): uint8 - setUint8Clamped(offset: any, value: any): void; -} -``` -[*CommonJS entry points:*](#commonjs-api) -``` -core-js/proposals/data-view-get-set-uint8-clamped -core-js/full/dataview/get-uint8-clamped -core-js/full/dataview/set-uint8-clamped -``` -[Examples](https://tinyurl.com/2h4zv8sw): -```js -const view = new DataView(new ArrayBuffer(1)); -view.setUint8Clamped(0, 100500); -console.log(view.getUint8Clamped(0)); // => 255 -``` - ##### [`Number.fromString`](https://github.com/tc39/proposal-number-fromstring)[⬆](#index) Module [`esnext.number.from-string`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.number.from-string.js) ```ts diff --git a/packages/core-js/stage/1.js b/packages/core-js/stage/1.js index d359930b40b1..28a5bfe12fca 100644 --- a/packages/core-js/stage/1.js +++ b/packages/core-js/stage/1.js @@ -6,7 +6,6 @@ require('../proposals/array-last'); require('../proposals/array-unique'); require('../proposals/collection-methods'); require('../proposals/collection-of-from'); -require('../proposals/data-view-get-set-uint8-clamped'); require('../proposals/keys-composition'); require('../proposals/math-extensions'); require('../proposals/math-signbit'); diff --git a/packages/core-js/stage/2.js b/packages/core-js/stage/2.js index 47e70763b141..a0186d2c7889 100644 --- a/packages/core-js/stage/2.js +++ b/packages/core-js/stage/2.js @@ -3,6 +3,7 @@ var parent = require('./2.7'); require('../proposals/array-is-template-object'); require('../proposals/async-iterator-helpers'); +require('../proposals/data-view-get-set-uint8-clamped'); require('../proposals/extractors'); require('../proposals/iterator-range'); require('../proposals/string-dedent');