Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! doc: improve documentation for safe Promise statics alternat…
…ives
  • Loading branch information
aduh95 committed Jul 10, 2022
commit 8ecae32d90cc61de7b86acdc6a50b6d2a53170d1
13 changes: 8 additions & 5 deletions doc/contributing/primordials.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,20 @@ Object.defineProperty(Object.prototype, Symbol.isConcatSpreadable, {
<code>%Promise.race%</code> iterate over an array</summary>

```js
const array = [promise];
const set = new SafeSet().add(promise);

// 1. Lookup @@iterator property on `array` (user-mutable if user-provided).
// 2. Lookup @@iterator property on %Array.prototype% (user-mutable).
// 3. Lookup `next` property on %ArrayIteratorPrototype% (user-mutable).
PromiseAll([]); // unsafe

PromiseAll(new SafeArrayIterator([])); // safe

const array = [promise];
const set = new SafeSet().add(promise);
// When running one of these functions on a non-empty iterable, it will also:
// 4. Lookup `then` property on `promise` (user-mutable if user-provided).
// 5. Lookup `then` property on `%Promise.prototype%` (user-mutable).
PromiseAll(array); // unsafe

PromiseAll(new SafeArrayIterator(array)); // unsafe
Comment thread
aduh95 marked this conversation as resolved.

PromiseAll(set); // unsafe

SafePromiseAll(array); // safe
Expand Down