wilk / microjob

A tiny wrapper for turning Node.js worker threads into easy-to-use routines for heavy CPU loads.
https://wilk.github.io/microjob/
MIT License
2.02k stars 47 forks source link

Use Generics instead of `any` #11

Closed motss closed 6 years ago

motss commented 6 years ago

Big thanks to the TypeScript rewrite. Stumbled upon the interface and thinking that this can be improved to leverage the power of the language.

https://github.com/wilk/microjob/blob/ed9bf9ed158514b6c24ca0e3500338b512fb5bab/src/interfaces.ts#L1-L4

I prefer here to accept Generics instead of using any:

// User can defined its own Generics
// TypeScript also accepts default types, but this requires certain version to support this IIRC.
export interface Config<T = {}, U = {}> {
  ctx?: T;
  data?: U;
}
wilk commented 6 years ago

I like it! I'll make the change asap: otherwise, please submit a PR and I'll be happy to merge it 💪

wilk commented 6 years ago

Fixed in https://github.com/wilk/microjob/pull/13