repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into combined-prs-branch
[poolifier.git]
/
examples
/
typescript
/
http-server-pool
/
fastify-worker_threads
/
src
/
worker.ts
diff --git
a/examples/typescript/http-server-pool/fastify-worker_threads/src/worker.ts
b/examples/typescript/http-server-pool/fastify-worker_threads/src/worker.ts
index 3f573647b34cef414a6b62baeb3227aefac29971..18e5c8a3cef5aef91512f609f30595c315c6b47c 100644
(file)
--- a/
examples/typescript/http-server-pool/fastify-worker_threads/src/worker.ts
+++ b/
examples/typescript/http-server-pool/fastify-worker_threads/src/worker.ts
@@
-1,4
+1,5
@@
import { ThreadWorker } from 'poolifier'
import { ThreadWorker } from 'poolifier'
+
import {
type BodyPayload,
type WorkerData,
import {
type BodyPayload,
type WorkerData,
@@
-9,11
+10,17
@@
class RequestHandlerWorker<
Data extends WorkerData<BodyPayload>,
Response extends WorkerResponse<BodyPayload>
> extends ThreadWorker<Data, Response> {
Data extends WorkerData<BodyPayload>,
Response extends WorkerResponse<BodyPayload>
> extends ThreadWorker<Data, Response> {
- private static readonly factorial: (n: number) => number = n => {
- if (n === 0) {
- return 1
+ private static readonly factorial: (n: number | bigint) => bigint = n => {
+ if (n === 0 || n === 1) {
+ return 1n
+ } else {
+ n = BigInt(n)
+ let factorial = 1n
+ for (let i = 1n; i <= n; i++) {
+ factorial *= i
+ }
+ return factorial
}
}
- return RequestHandlerWorker.factorial(n - 1) * n
}
public constructor () {
}
public constructor () {
@@
-25,8
+32,8
@@
class RequestHandlerWorker<
return {
body: {
number: RequestHandlerWorker.factorial(
return {
body: {
number: RequestHandlerWorker.factorial(
- workerData
?.body?.number as number
- )
+ workerData
!.body.number!
+ )
.toString()
}
} as unknown as Response
}
}
} as unknown as Response
}