From ff6b882ef5815b6beed3a35218bfd0832c835c1d Mon Sep 17 00:00:00 2001 From: Yoav Sarfaty <40428803+YoavSarfaty@users.noreply.github.com> Date: Thu, 25 Apr 2019 18:31:53 +0300 Subject: [PATCH 1/2] Update README.md --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b6862df..f8d6b56 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ # Multithread -Multithreading in js +Multithread is a little JavaScript library that helps you use multiple threads in the browser. +It uses webworkers but supports nested threads (I don't know any browser that supports nested webworkers), and it has a dead simple api. + +say you have a function `myFunction`, and you would like it to run in a background thread, all you need to do is use the global `multithread` function to create a new thread: + +```javascript +multithread(myFunction)(myArg) +``` +This will return a Promise that will be resolved once `myFunction` returns a value in the background thread, so you can use is with async/await (`myFunction` doesn't have to be a async function). + +But what if `myFunction` calls some other function `otherFunction`? you can give multithread an array of all function you may call so they will be written to the webworker: + +```javascript +multithread(myFunction, [otherFunction])(myArg) +``` + +That's it, it's as simple as that! + +## Performance From 1c687585c70c16648b7b6b43f436021b505ee7c3 Mon Sep 17 00:00:00 2001 From: Yoav Sarfaty <40428803+YoavSarfaty@users.noreply.github.com> Date: Thu, 25 Apr 2019 18:36:12 +0300 Subject: [PATCH 2/2] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f8d6b56..60660ec 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,4 @@ multithread(myFunction, [otherFunction])(myArg) That's it, it's as simple as that! ## Performance +You can measure the performance [in this merge sort test.](https://yoavsarfaty.github.io/Multithread/)