repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge dependabot/npm_and_yarn/mocha-10.5.0 into combined-prs-branch
[poolifier.git]
/
examples
/
typescript
/
worker.ts
diff --git
a/examples/typescript/worker.ts
b/examples/typescript/worker.ts
index 562b21477e31dd1aaa603a087eb33d3c92b4b130..7ab1fc5649e0c0ec366a67225304e9fc9577e47e 100644
(file)
--- a/
examples/typescript/worker.ts
+++ b/
examples/typescript/worker.ts
@@
-6,21
+6,21
@@
export interface MyData {
export interface MyResponse {
message: string
export interface MyResponse {
message: string
- data: MyData
+ data
?
: MyData
}
}
-class MyThreadWorker extends ThreadWorker<MyData,
Promise<MyResponse>
> {
+class MyThreadWorker extends ThreadWorker<MyData,
MyResponse
> {
constructor () {
constructor () {
- super(async (data: MyData) => await this.process(data), {
- maxInactiveTime: 60000
+ super(async (data
?
: MyData) => await this.process(data), {
+ maxInactiveTime: 60000
,
})
}
})
}
- private async process (data: MyData): Promise<MyResponse> {
+ private async process (data
?
: MyData): Promise<MyResponse> {
return await new Promise(resolve => {
setTimeout(() => {
resolve({ message: 'Hello from Worker :)', data })
return await new Promise(resolve => {
setTimeout(() => {
resolve({ message: 'Hello from Worker :)', data })
- }, 1000
0
)
+ }, 1000)
})
}
}
})
}
}