Skip to content

Commit

Permalink
move Promise.try to stage 2
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Feb 7, 2024
1 parent 7ec37c1 commit 3348b1a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Changelog
##### Unreleased
- [`Promise.try` proposal](https://github.com/tc39/proposal-promise-try) has been resurrected and [moved to stage 2](https://github.com/tc39/proposal-promise-try/issues/15)
- Fixed regression in `Set#intersection` feature detection
- Fixed a missed check in `Array#{ indexOf, lastIndexOf, includes }`, [#1325](https://github.com/zloirock/core-js/issues/1325), thanks [**@minseok-choe**](https://github.com/minseok-choe)
- Fixed a missed check in `Array#{ reduce, reduceRight }`, [#1327](https://github.com/zloirock/core-js/issues/1327), thanks [**@minseok-choe**](https://github.com/minseok-choe)
Expand Down
49 changes: 25 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
- [`Array.isTemplateObject`](#arrayistemplateobject)
- [`String.dedent`](#stringdedent)
- [`RegExp` escaping](#regexp-escaping)
- [`Promise.try`](#promisetry)
- [`Symbol` predicates](#symbol-predicates)
- [`Uint8Array` to / from base64 and hex](#uint8array-to-from-base64-and-hex)
- [Stage 1 proposals](#stage-1-proposals)
Expand All @@ -178,7 +179,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)
- [`Promise.try`](#promisetry)
- [`DataView` get / set `Uint8Clamped` methods](#dataview-get-set-iint8clamped-methods)
- [`Number.fromString`](#numberfromstring)
- [`Math` extensions](#math-extensions)
Expand Down Expand Up @@ -2680,6 +2680,30 @@ console.log(RegExp.escape('10$')); // => '\\x310\\$'
console.log(RegExp.escape('abcdefg_123456')); // => 'abcdefg_123456'
console.log(RegExp.escape('(){}[]|,.?*+-^$=<>\\/#&!%:;@~\'"`')); // => '\\(\\)\\{\\}\\[\\]\\|\\,\\.\\?\\*\\+\\-\\^\\$\\=\\<\\>\\\\\\/\\#\\&\\!\\%\\:\\;\\@\\~\\\'\\"\\`'
```
##### [`Promise.try`](https://github.com/tc39/proposal-promise-try)
Module [`esnext.promise.try`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.promise.try.js)
```js
class Promise {
static try(callbackfn: Function): Promise;
}
```
[*CommonJS entry points:*](#commonjs-api)
```js
core-js/proposals/promise-try
core-js(-pure)/full/promise/try
```
[*Examples*](https://goo.gl/k5GGRo):
```js
Promise.try(() => 42).then(it => console.log(`Promise, resolved as ${it}`));

Promise.try(() => { throw 42; }).catch(it => console.log(`Promise, rejected as ${it}`));

Promise.try(async () => 42).then(it => console.log(`Promise, resolved as ${it}`));

Promise.try(async () => { throw 42; }).catch(it => console.log(`Promise, rejected as ${it}`));
```
##### [`Symbol` predicates](https://github.com/tc39/proposal-symbol-predicates)[⬆](#index)
Modules [`esnext.symbol.is-registered-symbol`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.symbol.is-registered-symbol.js), [`esnext.symbol.is-well-known-symbol`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.symbol.is-well-known-symbol.js).
```js
Expand Down Expand Up @@ -2952,29 +2976,6 @@ core-js/full/typed-array/unique-by
].uniqueBy(it => it.uid); // => [{ id: 1, uid: 10000 }, { id: 3, uid: 10001 }]
```

##### [`Promise.try`](https://github.com/tc39/proposal-promise-try)
Module [`esnext.promise.try`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.promise.try.js)
```js
class Promise {
static try(callbackfn: Function): Promise;
}
```
[*CommonJS entry points:*](#commonjs-api)
```js
core-js/proposals/promise-try
core-js(-pure)/full/promise/try
```
[*Examples*](https://goo.gl/k5GGRo):
```js
Promise.try(() => 42).then(it => console.log(`Promise, resolved as ${it}`));
Promise.try(() => { throw 42; }).catch(it => console.log(`Promise, rejected as ${it}`));
Promise.try(async () => 42).then(it => console.log(`Promise, resolved as ${it}`));
Promise.try(async () => { throw 42; }).catch(it => console.log(`Promise, rejected as ${it}`));
```

##### [`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)
```js
Expand Down
1 change: 0 additions & 1 deletion packages/core-js/stage/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require('../proposals/number-from-string');
require('../proposals/object-iteration');
require('../proposals/observable');
require('../proposals/pattern-matching');
require('../proposals/promise-try');
require('../proposals/seeded-random');
require('../proposals/string-code-points');
require('../proposals/string-cooked');
Expand Down
1 change: 1 addition & 0 deletions packages/core-js/stage/2.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require('../proposals/array-is-template-object');
require('../proposals/async-iterator-helpers');
require('../proposals/iterator-range');
require('../proposals/map-upsert-stage-2');
require('../proposals/promise-try');
require('../proposals/regexp-escaping');
require('../proposals/string-dedent');
require('../proposals/symbol-predicates-v2');
Expand Down

0 comments on commit 3348b1a

Please sign in to comment.