threads.js

๐Ÿงต Make web workers & worker threads as simple as a function call.

MIT License

Downloads
700K
Stars
3K
Committers
23

Bot releases are hidden (Show)

threads.js - v1.7.0 Latest Release

Published by andywer about 3 years ago

Maintenance release shipping small bug fixes mostly and some minor dependency version bumps.

Bug fixes

  • Export BlobWorker from mjs endpoint (#379)
  • Fix relative worker paths on Windows (#390)
  • Fix type compatibility with node 10+ (#392)
threads.js - v1.6.5

Published by andywer over 3 years ago

Small patch release, fixing some TypeScript issues.

Bug fixes

  • Update observable-fns to fix issues with TypeScript 4.3 (#374)
threads.js - v1.6.4

Published by andywer over 3 years ago

Small patch release fixing the type resolution around Transfer(). Also updated dependencies.

Bug fixes

  • Resolve transferable object types on call (#352)
  • Allow passing workerData for node worker_threads (#318, by @haggholm)

Chores

  • Updated dependency versions
  • Updated the CI / build setup (#351, by @aminya)
threads.js - v1.6.3

Published by andywer over 4 years ago

A small patch that fixes pool task promises not resolving as expected.

Bug fixes

  • Pool task promises pending forever if task completed too quickly (#270)
threads.js - v1.6.2

Published by andywer over 4 years ago

A small patch release that makes worker observables actually being unsubscribed from when the proxied observable in the master thread is being unsubscribed.

Bug fixes

  • Proxy unsubscribing from observables (#262)
threads.js - v1.6.1

Published by andywer over 4 years ago

A small patch release that fixes the ES modules, so they work with node.js. 1.5.0 should have fixed them already, but it turned out there was another issue.

Bug fixes

  • Add conditional exports to package.json (#261)
threads.js - v1.6.0

Published by andywer over 4 years ago

This minor release introduces an exciting new feature: The BlobWorker ๐Ÿ‘ทโ€โ™€๏ธ๐Ÿ‘ทโ€โ™‚๏ธ

Use the BlobWorker to spawn workers from in-memory code. You can create stand-alone bundles that ship the master and the worker code in one file, without the need to reference a separate worker file at runtime.

Read its documentation for more details.

Features

  • Spawn worker from blob / inlined bundle (#211)
threads.js - v1.5.0

Published by andywer over 4 years ago

This is a minor release, exposing the isWorkerRuntime() function to you and fixing compatibility with node.js v13+ ES modules โœจ

Features

  • Expose isWorkerRuntime() (#225)

Bug fixes

  • Make the package consumable by node.js native ES modules (#220)
threads.js - v1.4.1

Published by andywer over 4 years ago

A small patch fixing two issues. One of them being a fix for another fix that turned out to not yet have solved the underlying issue with ASAR packaging in Electron apps.

Bug fixes

  • Fix the last release's ASAR path resolution fix (#236)
  • Report original error, too, on recursive worker errors (#235)
threads.js - v1.4.0

Published by andywer over 4 years ago

Another minor release, yay!

This release introduces support for setups that were not supported before and fixes a bug.

Features

  • Allow spawning workers from ASAR-packed Electron app (#226 โ€“ thanks, @dinataranis & @raz-sinay)
  • Support webpack node externals (#224, by @chingyawhao)

Bug fixes

  • Pass native worker options to ts-node workers (#230, by @rysi3k)
threads.js - v1.3.1

Published by andywer over 4 years ago

Here comes a small patch release fixing an edge-casy, but annoying bug in the workers.

Bug fixes

  • Prevent infinite recursion if uncaught error reporting throws (#219)
threads.js - v1.3.0

Published by andywer over 4 years ago

A small minor release shipping a small new feature and fixes some TypeScript warnings.

New features

  • Allow passing resource limits to worker threads (#216 by @haggholm)

Bug fixes

  • Update observable-fns to get rid of TypeScript errors (#210)
threads.js - v1.2.0

Published by andywer over 4 years ago

Small minor release, shipping a new way to wait for pool tasks to complete.

The new pool.settled() method now allows you to await the completion of all pool tasks. The difference to pool.completed() is that the promise won't be rejected if a task fails โ€“ the returned promise will always successfully resolve to an array of errors as thrown by failing tasks.

New features

  • Add pool.settled() (#208)
threads.js - v1.1.0

Published by andywer over 4 years ago

A minor release introducing the timeout option and custom data serializers.

The new custom serializers allow passing class instances and other non-trivial data between threads, that normally cannot be passed using the underlying .postMessage() method. Read the docs for details.

New features

  • Add custom data serialization (#207)
  • Add timeout option to spawn() (#206, credits to @haggholm)
threads.js - v1.0.2

Published by andywer over 4 years ago

A small patch that fixes error handling for postMessage() errors when calling a worker from the main thread.

Bug fixes

  • Handle postMessage() errors in main thread (#202)
threads.js - v1.0.1

Published by andywer over 4 years ago

A small but important patch release. Fixes some webpack bundling troubles and terminates workers gracefully on SIGTERM.

Bug fixes

  • Fix Module not found error (#194)
  • Gracefully terminate workers on SIGTERM (#198)
threads.js - v1.0.0

Published by andywer almost 5 years ago

Finally, after about half a year in beta here it is โ€“ threads.js v1.0 ๐Ÿš€๐ŸŽ‰

It has not been easy, but it's been worth the effort. Thanks to everyone who contributed to the v1.0 release! There were and still are many different ways to contribute.

Changes since v0.12

Version 1.0 is a complete rewrite of the library with a new API and written in TypeScript. It is the result of all the lessons learned from working on and working with v0.x.

The most noticeable changes are:

  • New functional Promise- & Observable-based API
  • Transparent calls to worker code
  • First-class TypeScript support
  • First-class webpack support via threads-plugin

This also means that you can now write worker code pretty intuitively and use worker functions just by calling them like any other function.

Since the new API is Promise-based, error handling now finally feels trivial. You might notice there is no more UMD build. If you feel like this is an issue you can vote to add it again in #191.

Changes since v1.0.0-beta.9

  • Fix Transfer() function signature (#190)
  • Add maxQueuedJobs option to pool (#188)
  • Consistenly using observable-fns now (#185)
  • Small performance improvements (#189)
  • Some code refactorings (#186)

Future

A couple of features are still in discussion โ€“ head over to Issues to check them out. Here is a brief summary.

  • Allow passing callbacks to workers (#145)
  • IE11 support (#171)
  • Easy worker-to-worker communication (#169)
  • Turn functions into workers (no extra worker file)
  • Custom serializers/deserializers for data passed to/from workers

If you have any feedback you would like to share, feel free to open an issue or ping @andywer via gitter.im / twitter.com.

You can also help this project. Engage in discussions, contribute code, improve the documentation, become a sponsor or just simply star the repository and spread the word.

Happy hacking!

threads.js - v1.0.0-beta.9

Published by andywer almost 5 years ago

This small path release fixes some TypeScript issues. Integration tests have been added to prevent future regressions.

Bug fixes

  • Declaration files now work if the app's tsconfig compilerOptions.lib does not contain dom (#138)
  • Declaration files now work if the app's tsconfig has compilerOptions.esModuleInterOp not set (#138)
threads.js - v1.0.0-beta.8

Published by andywer almost 5 years ago

Another tiny patch release.

Bug fixes

  • Allows master threads on a file:// URL to create workers from relative path
  • Prevent error when importing threads in a web worker and browser doesn't support creating workers in workers
threads.js - v1.0.0-beta.7

Published by andywer almost 5 years ago

Bug fixes

  • Fix some types and type inference around promises & observables returned by threads (#175)