josdejong / workerpool

Offload tasks to a pool of workers on node.js and in the browser
Apache License 2.0
2.04k stars 148 forks source link

Export more types #416

Closed joshkel closed 8 months ago

joshkel commented 8 months ago

This allows code using workerpool to easily reference pool types. For example, I could write code similar to the following in workerpool 8, but in workerpool 9, I could not find an easy way to access these types, since they're just imports within the generated index.d.ts.

import { pool, type WorkerPoolOptions, type WorkerPool } from 'workerpool';

function getOptions(): WorkerPoolOptions { /* ... */ };
function makeMyPool(): WorkerPool {
  const myPool = pool(getOptions());
  // initialize
  return myPool;
}

(workerpool 9's build-in types also rename WorkerPool to Pool, but that's an easy change to make in calling code.)

josdejong commented 8 months ago

Thanks for the improvement @joshkel, this makes sense!

josdejong commented 8 months ago

Published now in v9.0.1. Please let me know if you encounter more issues with the types!

joshkel commented 8 months ago

Works great. Thanks, @josdejong!