Move an async function into its own thread. A simplified single-function version of workerize, offering the same performance as direct Worker usage. Greenlet only supports browser environments, since it uses Web Workers. For use in a NodeJS environment, Web Workers must be polyfilled using a library like node-webworker. Accepts an async function with, produces a copy of it that runs within a Web Worker. Never call greenlet() dynamically. Doing so creates a new Worker thread for every call. Since Greenlets can't rely on surrounding scope anyway, it's best to always create them at the "top" of your module. Greenlet is most effective when the work being done has relatively small inputs/outputs. One such example would be fetching a network resource when only a subset of the resulting information is needed. Greenlet will even accept and optimize transferables as arguments to and from a greenlet worker function.

Features

  • Move an async function into its own thread
  • A simplified single-function version of workerize
  • Greenlet only supports browser environments
  • Web Workers must be polyfilled using a library like node-webworker
  • Greenlet is most effective when the work being done has relatively small inputs/outputs

Project Samples

Project Activity

See All Activity >

Categories

System

License

MIT License

Follow Greenlet

Greenlet Web Site

You Might Also Like
MongoDB Atlas runs apps anywhere Icon
MongoDB Atlas runs apps anywhere

Deploy in 115+ regions with the modern database for every enterprise.

MongoDB Atlas gives you the freedom to build and run modern applications anywhere—across AWS, Azure, and Google Cloud. With global availability in over 115 regions, Atlas lets you deploy close to your users, meet compliance needs, and scale with confidence across any geography.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of Greenlet!

Additional Project Details

Programming Language

JavaScript

Related Categories

JavaScript System Software

Registered

2021-12-07