title: JavaScript native fibers
body: <p>Do you know if native fiber support is planned in a future version of JavaScript? Indeed, it would be very cool if it was possible to write something like :</p>
  <pre><code>console.log(&quot;sleep 3s...&quot;);
  
  const value = wait (resolve, reject) =&gt; {
      setTimeout(
          () =&gt; resolve(5),
          3_000
      );
  };
  
  console.log(&quot;value =&quot;, value);    // value = 5 (after 3s)
  </code></pre>
  <p>Of course it is possible to have a similar result with <code>async/await</code> but the fibers would allow you to pause anywhere in the code without having to be in a function declared <code>async</code>.</p>
  <p>Indeed it can become very problematic to convert a synchronous function into an asynchronous one because it is necessary to transform all the dependencies in cascade:</p>
  <pre><code>const a = () =&gt; b() + 1;
  const b = () =&gt; c() + 2;
  const c = () =&gt; 5;
  const value = a();
  </code></pre>
  <p>Ok now c becomes asynchronous...</p>
  <pre><code>const a = async () =&gt; (await b()) + 1;
  const b = async () =&gt; (await c()) + 2;
  const c = async () =&gt; new Promise(resolve =&gt; { ... resolve(5) });
  const value = await a();
  </code></pre>
  <p>This is a simple example!
  With fiber, it would be much easier:</p>
  <p><code>const c = () =&gt; wait resolve =&gt; { ... resolve(5) }</code></p>
  <p>No need to modify a nor b !</p>
  <p>PHP has implemented fibers since version 8 :</p>
  <p><a href="https://www.php.net/manual/en/language.fibers.php" rel="nofollow noreferrer">https://www.php.net/manual/en/language.fibers.php</a></p>
  <ul>
  <li>Do you know if native fiber support is planned in a future version of JavaScript?</li>
  <li>Do you know if there is a place where we can see the future innovations planned in JavaScript?</li>
  <li>Is there a place where we can propose innovations for JavaScript?</li>
  <li>Do you think that native fiber support would be a good idea?</li>
  </ul>
  <p>Thank you in advance!</p>