Comments (8)
Yeah, sure!
I'll rewrite microjob in Typescript so it will be available for typescripter!
from microjob.
@nomeyer thank you for using it!
Sorry for the delay: microjob has been rewritten in TS in version 0.2.0 π
I invite you all to try it and to open new issues and PRs!
from microjob.
Ok, thanks, then feel free to open a new issue for the related problem πͺ
from microjob.
Thanks for your quick reply π
If you think this should be better highlighted inside the docs, then I'll put it asap.
No I think the docs are pretty clear that one can use a sync or async function π
My jobs are async so I was hoping to do something like this, that's why I'm trying to get async function doStuff
to work. I could try to rewrite my worker without async
/ await
but the two examples in my previous example should be equivalent π€ I'll see if I can find some time for more experiments.
from microjob.
Hey @wilk, thanks for this package & being willing to rewrite it in Typescript!
I'm looking for a clarificationΒ β is it currently possible to use it with Typescript (as an untyped library), or is it just not possible before the rewrite?
I was playing around with it and I can't seem to get around this error:
ReferenceError: tslib_1 is not defined
at anonymous (eval at parentPort.on (/app/node_modules/microjob/src/worker.js:10:5), <anonymous>:9:5)
at __executor__ (eval at parentPort.on (/app/node_modules/microjob/src/worker.js:10:5), <anonymous>:30:3)
at MessagePort.parentPort.on (/app/node_modules/microjob/src/worker.js:12:27)
at MessagePort.emit (events.js:182:13)
at MessagePort.onmessage (internal/worker.js:66:8)
Thanks!
from microjob.
@nomeyer I'm a TypeScript user and have tried using it with TypeScript. Do you have a reduced test case?
from microjob.
Hey @wilk, thanks a lot for that release, much appreciated π
Unfortunately, I'm still getting the same error (ReferenceError: tslib_1 is not defined
) β does it mean anything to you?
FWIW after gradually stripping things out of my worker function I managed to get this to work:
export function doStuff(data: IStuff): Promise<IStuff> {
console.log(data);
return Promise.resolve(data);
}
And I get the ReferenceError: tslib_1 is not defined
as soon as I add async
, like so:
export async function doStuff(data: IStuff): Promise<IStuff> {
console.log(data);
return data;
}
from microjob.
Hi @nomeyer !
Thank you for using it and for reporting this issue!
Well, I don't understand why it's giving you that error but it makes sense using an async function instead of a sync one with a Promise.resolve
call.
However, you should be able to define a doStuff
sync function like so:
export function doStuff(data: IStuff): IStuff {
console.log(data);
return data;
}
If you think this should be better highlighted inside the docs, then I'll put it asap.
from microjob.
Related Issues (20)
- __awaiter is not defined for async jobs HOT 4
- Shared Memory (SharedArrayBuffer) HOT 5
- Node 12.5 Deprecation Warning (worker.terminate()) HOT 1
- Can't install with node 10.x HOT 2
- Single file build HOT 7
- Persistent context HOT 7
- Cannot find module 'worker_threads' HOT 3
- Clarification about using in http server HOT 2
- ts-node support/example? HOT 5
- unsupported in {zeit/pkg} HOT 2
- Functions in nested objects are not passed. HOT 2
- save data to mongoose HOT 4
- Hackernoon pictures are missing? HOT 2
- ReferenceError: immutable_1 is not defined when using 'immutable' library HOT 3
- function is not defined when using async function using babel and Typescript in development HOT 1
- function could not be cloned HOT 1
- Take longer time than native worker_thread HOT 2
- While loop only run once inside worker thread
- Microjob doesn't work with typescript HOT 1
- Confused about starting multiple worker threads HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from microjob.