File tree Expand file tree Collapse file tree 4 files changed +12
-9
lines changed
protocols/workers/internal Expand file tree Collapse file tree 4 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " tgrid" ,
3- "version" : " 0.10.1 " ,
3+ "version" : " 0.10.2 " ,
44 "main" : " lib/index.js" ,
55 "typings" : " lib/index.d.ts" ,
66 "exports" : {
Original file line number Diff line number Diff line change @@ -5,20 +5,20 @@ import { NodeModule } from "../../../../utils/internal/NodeModule";
55 */
66export class ProcessChannel {
77 public static postMessage ( message : any ) : void {
8- NodeModule . process . get ( ) . send ! ( message ) ;
8+ NodeModule . process ( ) . send ! ( message ) ;
99 }
1010
1111 public static close ( ) : void {
12- NodeModule . process . get ( ) . exit ( ) ;
12+ NodeModule . process ( ) . exit ( ) ;
1313 }
1414
1515 public static set onmessage ( listener : ( event : MessageEvent ) => void ) {
16- NodeModule . process . get ( ) . on ( "message" , ( msg ) => {
16+ NodeModule . process ( ) . on ( "message" , ( msg ) => {
1717 listener ( { data : msg } as MessageEvent ) ;
1818 } ) ;
1919 }
2020
2121 public static is_worker_server ( ) : boolean {
22- return ! ! NodeModule . process . get ( ) . send ;
22+ return ! ! NodeModule . process ( ) . send ;
2323 }
2424}
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export async function ThreadPort() {
1212 const { parentPort } = await NodeModule . thread . get ( ) ;
1313 if ( ! parentPort ) throw new Error ( "This is not a worker thread." ) ;
1414
15- const process = NodeModule . process . get ( ) ;
15+ const process = NodeModule . process ( ) ;
1616 class ThreadPort {
1717 public static postMessage ( message : any ) : void {
1818 parentPort ! . postMessage ( message ) ;
Original file line number Diff line number Diff line change @@ -31,7 +31,10 @@ export namespace NodeModule {
3131 export const ws : Singleton < Promise < typeof __ws > > = new Singleton (
3232 ( ) => import ( "ws" ) ,
3333 ) ;
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+ } ;
3738}
39+
40+ const __global = is_node ( ) ? global : undefined ;
You can’t perform that action at this time.
0 commit comments