Last active
February 21, 2026 02:54
-
-
Save espio999/8049a12843f747bf65fb883236e8db96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <script> | |
| let isInlineExecuted = false; | |
| /* | |
| let unlock = null; | |
| let forceOpen = null; | |
| const gate = new Promise((resolve, reject) => { | |
| unlock = resolve; | |
| forceOpen = reject; | |
| }); | |
| */ | |
| const { | |
| promise: gate, | |
| resolve: unlock, | |
| reject: forceOpen | |
| } = Promise.withResolvers(); | |
| </script> | |
| <script> | |
| function wait_long(){ | |
| const t = 10000; | |
| const f = () => { | |
| console.log("お待たせ"); | |
| unlock(); | |
| console.log("unlock"); | |
| } | |
| setTimeout(f, t); | |
| } | |
| function inline_logic(){ | |
| isInlineExecuted = true; | |
| try{ | |
| console.log("inline logic - start"); | |
| if (Math.random() < 0.5) { | |
| throw new Error("error occured in inline logic"); | |
| } | |
| wait_long(); | |
| console.log("inline logic - completed"); | |
| } | |
| catch (e){ | |
| console.log(e); | |
| forceOpen(); | |
| } | |
| } | |
| if (Math.random() < 0.5) { | |
| inline_logic(); | |
| } | |
| else{ | |
| console.log("inline logic - skipped"); | |
| unlock(); | |
| console.log("unlock"); | |
| } | |
| </script> | |
| <script src="promise-unlock.js"></script> | |
| </head> | |
| <body></body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment