File tree 4 files changed +12
-9
lines changed
protocols/workers/internal
4 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " tgrid" ,
3
- "version" : " 0.10.1 " ,
3
+ "version" : " 0.10.2 " ,
4
4
"main" : " lib/index.js" ,
5
5
"typings" : " lib/index.d.ts" ,
6
6
"exports" : {
Original file line number Diff line number Diff line change @@ -5,20 +5,20 @@ import { NodeModule } from "../../../../utils/internal/NodeModule";
5
5
*/
6
6
export class ProcessChannel {
7
7
public static postMessage ( message : any ) : void {
8
- NodeModule . process . get ( ) . send ! ( message ) ;
8
+ NodeModule . process ( ) . send ! ( message ) ;
9
9
}
10
10
11
11
public static close ( ) : void {
12
- NodeModule . process . get ( ) . exit ( ) ;
12
+ NodeModule . process ( ) . exit ( ) ;
13
13
}
14
14
15
15
public static set onmessage ( listener : ( event : MessageEvent ) => void ) {
16
- NodeModule . process . get ( ) . on ( "message" , ( msg ) => {
16
+ NodeModule . process ( ) . on ( "message" , ( msg ) => {
17
17
listener ( { data : msg } as MessageEvent ) ;
18
18
} ) ;
19
19
}
20
20
21
21
public static is_worker_server ( ) : boolean {
22
- return ! ! NodeModule . process . get ( ) . send ;
22
+ return ! ! NodeModule . process ( ) . send ;
23
23
}
24
24
}
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export async function ThreadPort() {
12
12
const { parentPort } = await NodeModule . thread . get ( ) ;
13
13
if ( ! parentPort ) throw new Error ( "This is not a worker thread." ) ;
14
14
15
- const process = NodeModule . process . get ( ) ;
15
+ const process = NodeModule . process ( ) ;
16
16
class ThreadPort {
17
17
public static postMessage ( message : any ) : void {
18
18
parentPort ! . postMessage ( message ) ;
Original file line number Diff line number Diff line change @@ -31,7 +31,10 @@ export namespace NodeModule {
31
31
export const ws : Singleton < Promise < typeof __ws > > = new Singleton (
32
32
( ) => import ( "ws" ) ,
33
33
) ;
34
- export const process : Singleton < typeof __process > = new Singleton ( ( ) =>
35
- is_node ( ) ? global . process : undefined ! ,
36
- ) ;
34
+ export const process = ( ) => {
35
+ if ( __global === undefined ) throw new Error ( "Not a node environment" ) ;
36
+ return __global . process ;
37
+ } ;
37
38
}
39
+
40
+ const __global = is_node ( ) ? global : undefined ;
You can’t perform that action at this time.
0 commit comments