Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is regenerator-runtime npm package used for?

I've noticed it in my company's codebase and it has 30M downloads per week so I'm curious about its importance.

like image 458
flow24 Avatar asked Dec 20 '20 09:12

flow24


1 Answers

regenerator-runtime is the runtime support for compiled/transpiled async functions. (It may well have other uses, but this is the predominant one.)

When you use a compiler like Babel that compiles modern JavaScript into earlier JavaScript (a process sometimes called transpiling), one of the things you can do is compile async functions to something that will run on JavaScript engines that don't support async functions (such as the increasingly-irrelevant IE11). Babel does the syntax transformation, but the resulting code relies on runtime support from regenerator-runtime.

like image 179
T.J. Crowder Avatar answered Nov 07 '22 19:11

T.J. Crowder