Skip to content

Commit 7a8520d

Browse files
committed
Add 2025-09 slides
1 parent 4bcc50c commit 7a8520d

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

slides/2025-09-stage-1.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
routerMode: hash # for GH hosting
3+
theme: default
4+
title: Native promise predicate for Stage 1 or 2
5+
info: |
6+
Proposal for exposing a native promise predicate
7+
class: text-center
8+
drawings:
9+
persist: false
10+
# slide transition: https://sli.dev/guide/animations.html#slide-transitions
11+
transition: fade
12+
fonts:
13+
local: ["Consolas", "Fira Code", "monospace"]
14+
layout: cover
15+
---
16+
17+
# Native promise predicate <br /> for Stage 1 (or 2)
18+
19+
Mathieu Hofman (@mhofman)
20+
21+
---
22+
23+
# Motivation
24+
25+
Native promises are recognized and don't use `.then` in some operations.
26+
27+
<v-click>
28+
29+
Native promises
30+
31+
```js {1-4|*|*|*|5}
32+
const promise = Promise.resolve(42);
33+
typeof promise.then === 'function';
34+
35+
const v = await promise; // does not call promise.then
36+
Promise.resolve(promise) === promise; // pass-through
37+
```
38+
39+
</v-click>
40+
41+
<div v-click="3">
42+
43+
Thenables
44+
45+
```js {1-3|*|4}{at:4}
46+
const thenable = { then(onFulfilled) { onFulfilled(42) } };
47+
48+
const v = await thenable; // does call thenable.then
49+
Promise.resolve(thenable) !== thenable; // does not pass-through, calls thenable.then, allocates new promise
50+
```
51+
52+
</div>
53+
54+
<div v-click="5">
55+
56+
--> Cannot build a side-effect-free predicate
57+
58+
</div>
59+
60+
---
61+
62+
# Precedents
63+
64+
<v-clicks>
65+
66+
* `Error.isError`
67+
* pure brand check
68+
* implies some stack information is associated
69+
* `Array.isArray`
70+
* pierces proxy
71+
* indicates when object treated as array, e.g. in `JSON.serialize`
72+
73+
</v-clicks>
74+
75+
---
76+
77+
# Proposal
78+
79+
Predicate that cleanly exposes `IsPromise` AO
80+
81+
<v-clicks>
82+
83+
* `Promise.isPromise` ?
84+
85+
* `Promise.isNativePromise` ?
86+
87+
* Some other less ergonomic but clean brand check ?
88+
89+
</v-clicks>
90+
91+
<v-click>
92+
93+
## Membrane transparency
94+
95+
<v-clicks at="5">
96+
97+
* Predicate does not pierce proxies
98+
* Like `Error.isError`
99+
* It's already possible to brand check promises with side-effects
100+
* It's better for membranes to create a new native promise (pass by copy)
101+
* Need a predicate to know which thenables are native promises
102+
103+
</v-clicks>
104+
105+
</v-click>
106+
107+
---
108+
layout: section
109+
---
110+
# Stage 1?
111+
112+
<br/>
113+
114+
Predicate for native promises
115+
116+
---
117+
layout: section
118+
---
119+
# Stage 2?
120+
121+
<br/>
122+
123+
`Promise.isXXX()`
124+
125+
[Spec text](/)
126+
127+
`isPromise` ? `isNativePromise` ?

0 commit comments

Comments
 (0)