Pasquale Mangialavori Posted on Jan 26, 2021 Typewriter effect with vanilla async generators functions #javascript #typewriter #asyncgenerators #webdev Easy peasy lemon squeezy! Top comments (2) Subscribe Submit Preview Dismiss Collapse Expand lionel-rowe lionel-rowe lionel-rowe Follow Joined May 19, 2019 • Jan 26 '21 Dropdown menu Copy link Hide Nice demo! Note that strings are already iterable, so you can simplify spell like this: async function* spell({ sentence, slowness = 75 }) { for (const char of sentence) { await delay(slowness); yield char; } } Enter fullscreen mode Exit fullscreen mode Collapse Expand Pasquale Mangialavori Pasquale Mangialavori Pasquale Mangialavori Follow Location Barcelona, Spain Work Front-End Developer Joined Nov 27, 2018 • Jan 26 '21 Dropdown menu Copy link Hide True! It actually implements Symbol.iterator. thanks for pointing it out. :) Code of Conduct • Report abuse
Top comments (2)
Nice demo! Note that strings are already iterable, so you can simplify
spelllike this:True! It actually implements Symbol.iterator. thanks for pointing it out. :)