repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps-dev): apply updates
[poolifier.git]
/
examples
/
typescript
/
websocket-server-pool
/
ws-worker_threads
/
src
/
worker.ts
diff --git
a/examples/typescript/websocket-server-pool/ws-worker_threads/src/worker.ts
b/examples/typescript/websocket-server-pool/ws-worker_threads/src/worker.ts
index a3b106c64d341d55d3a94d327c056da227f6bfdf..e1b67193a2e944de72ef04e16871793eefa646b7 100644
(file)
--- a/
examples/typescript/websocket-server-pool/ws-worker_threads/src/worker.ts
+++ b/
examples/typescript/websocket-server-pool/ws-worker_threads/src/worker.ts
@@
-1,4
+1,5
@@
import { ThreadWorker } from 'poolifier'
import { ThreadWorker } from 'poolifier'
+
import {
type DataPayload,
type WorkerData,
import {
type DataPayload,
type WorkerData,
@@
-9,11
+10,17
@@
class RequestHandlerWorker<
Data extends WorkerData<DataPayload>,
Response extends WorkerResponse<DataPayload>
> extends ThreadWorker<Data, Response> {
Data extends WorkerData<DataPayload>,
Response extends WorkerResponse<DataPayload>
> extends ThreadWorker<Data, Response> {
- private static readonly factorial = (n: number): number => {
- if (n === 0) {
- return 1
+ private static readonly factorial = (n: number | bigint): bigint => {
+ 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 () {