@@ -25,84 +25,45 @@ npm install sendmessage --save
2525
2626### master.js
2727
28- ``` js
29- var childprocess = require (' child_process' );
30- var sendmessage = require (' sendmessage' );
28+ ``` ts
29+ import { fork } from ' node:child_process' ;
30+ import sendmessage from ' sendmessage' ;
31+
32+ const worker = fork (' ./worker.js' );
3133
32- var worker = childprocess .fork (' ./worker.js' );
33- sendmessage (worker, {hi: ' this is a message to worker' });
34+ sendmessage (worker , { hi: ' this is a message to worker' });
3435```
3536
3637### worker.js
3738
38- ``` js
39- var sendmessage = require ( ' sendmessage' ) ;
39+ ``` ts
40+ import sendmessage from ' sendmessage' ;
4041
41- sendmessage (process , {hello: ' this is a message to master' });
42+ sendmessage (process , { hello: ' this is a message to master' });
4243```
4344
4445## API
4546
46- ### #sendmessage(childprocess , message)
47+ ### #sendmessage(childProcess , message)
4748
4849Send a cross process message.
4950If a process is not child process, this will just call ` process.emit('message', message) ` instead.
5051
51- - childprocess : child process instance
52+ - childProcess : child process instance
5253- message: the message need to send
5354
5455``` js
55- sendmessage (process , {hello: ' this is a message to master' });
56+ sendmessage (process , { hello: ' this is a message to master' });
5657```
5758
5859You can switch to ` process.emit('message', message) ` using ` process.env.SENDMESSAGE_ONE_PROCESS `
5960
60- ## Test
61-
62- ``` bash
63- npm install
64- npm test
65- ```
66-
67- ### Coverage
68-
69- ``` bash
70- npm run ci
71- ```
72-
7361## License
7462
75- (The MIT License)
76-
77- Copyright (c) 2014 - 2015 fengmk2
< [email protected] > and other contributors
78-
79- Permission is hereby granted, free of charge, to any person obtaining
80- a copy of this software and associated documentation files (the
81- 'Software'), to deal in the Software without restriction, including
82- without limitation the rights to use, copy, modify, merge, publish,
83- distribute, sublicense, and/or sell copies of the Software, and to
84- permit persons to whom the Software is furnished to do so, subject to
85- the following conditions:
86-
87- The above copyright notice and this permission notice shall be
88- included in all copies or substantial portions of the Software.
89-
90- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
91- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
92- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
93- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
94- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
95- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
96- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
97-
98- <!-- GITCONTRIBUTOR_START -->
63+ [ MIT] ( LICENSE )
9964
10065## Contributors
10166
102- | [ <img src =" https://avatars.githubusercontent.com/u/156269?v=4 " width =" 100px; " /><br /><sub ><b >fengmk2</b ></sub >] ( https://github.com/fengmk2 ) <br />| [ <img src =" https://avatars.githubusercontent.com/u/360661?v=4 " width =" 100px; " /><br /><sub ><b >popomore</b ></sub >] ( https://github.com/popomore ) <br />| [ <img src =" https://avatars.githubusercontent.com/u/32174276?v=4 " width =" 100px; " /><br /><sub ><b >semantic-release-bot</b ></sub >] ( https://github.com/semantic-release-bot ) <br />| [ <img src =" https://avatars.githubusercontent.com/u/7581901?v=4 " width =" 100px; " /><br /><sub ><b >sjfkai</b ></sub >] ( https://github.com/sjfkai ) <br />|
103- | :---: | :---: | :---: | :---: |
104-
105-
106- This project follows the git-contributor [ spec] ( https://github.com/xudafeng/git-contributor ) , auto updated at ` Tue Jun 13 2023 20:42:15 GMT+0800 ` .
67+ [ ![ Contributors] ( https://contrib.rocks/image?repo=node-modules/sendmessage )] ( https://github.com/node-modules/sendmessage/graphs/contributors )
10768
108- <!-- GITCONTRIBUTOR_END -->
69+ Made with [ contributors-img ] ( https://contrib.rocks ) .
0 commit comments