Skip to content

lyrl/greenlet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Greenlet

Greenlet npm travis

Move an async function into its own thread.

A simplified single-function version of workerize.

The name is somewhat of a poor choice, but it was available on npm.

Installation & Usage

npm i -S greenlet

Accepts an async function with, produces a copy of it that runs within a Web Worker.

⚠️ Caveat: the function you pass should be pure, since they get executed in an isolated scope.

greenlet(Function) -> Function

Example

import greenlet from 'greenlet'

let get = greenlet(async url => {
	let res = await fetch(url)
	return await res.json()
})

console.log(await get('/foo'))

License

MIT

About

🦎 Move an async function into its own thread.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%