{"name":"sendmessage","version":"3.0.2","engines":{"node":">= 18.19.0"},"description":"Send a cross process message if message channel is connected.","scripts":{"lint":"eslint --cache src --ext .ts","pretest":"npm run prepublishOnly && attw --pack","test":"npm run lint && mocha --exit -t 5000 test/*.test.js","ci":"c8 -r lcov -r text -r text-summary npm test","prepublishOnly":"tshy && tshy-after"},"devDependencies":{"@arethetypeswrong/cli":"^0.17.1","@eggjs/tsconfig":"1","@types/mocha":"10","@types/node":"22","c8":"^10.1.2","eslint":"8","eslint-config-egg":"14","mm":"3","mocha":"^11.0.1","tshy":"^3.0.2","tshy-after":"1","typescript":"5"},"homepage":"https://github.com/node-modules/sendmessage","repository":{"type":"git","url":"git://github.com/node-modules/sendmessage.git"},"bugs":{"url":"https://github.com/node-modules/sendmessage/issues"},"keywords":["sendmessage","send","cluster","message","channel closed"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"https://github.com/fengmk2"},"license":"MIT","type":"module","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"types":"./dist/commonjs/index.d.ts","main":"./dist/commonjs/index.js","module":"./dist/esm/index.js","gitHead":"f073f95cca8c63ca1d181ed4f36f6001d38c01ce","_id":"sendmessage@3.0.2","_nodeVersion":"22.19.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-nQWHp6obvkK9/ExmY8hjqzVPgcgAh1ZRgetV8bPcmXgQl6ujJVwWPeAfkk0aB+PKi4v4GY59Jxa0+c1qwXsrRw==","shasum":"0535a190ea7d17e44eb1873eb98febada5612177","tarball":"http://registry-npm.ywwl.com/sendmessage/download/sendmessage-3.0.2.tgz","fileCount":11,"unpackedSize":17962,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/sendmessage@3.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDppkF7OkaoetKxs1Ehe/MYSghuMbejw4oFCb4MuC5jTAiEAlT+ZUmpi63OX/35bnNJfe69lo5szpyRQnleuYPw4Ylo="}],"size":4918,"noattachment":false,"key":"/sendmessage/-/sendmessage-3.0.2.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c3998733-6aa9-4579-97f2-04322471a52f"}},"directories":{},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sendmessage_3.0.2_1758988139591_0.43411934584428913"},"_hasShrinkwrap":false,"readme":"# sendmessage\n\n[![NPM version][npm-image]][npm-url]\n[![CI](https://github.com/node-modules/sendmessage/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/sendmessage/actions/workflows/nodejs.yml)\n[![Test coverage][codecov-image]][codecov-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/sendmessage.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/sendmessage\n[download-image]: https://img.shields.io/npm/dm/sendmessage.svg?style=flat-square\n[download-url]: https://npmjs.org/package/sendmessage\n[codecov-image]: https://codecov.io/gh/node-modules/sendmessage/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/node-modules/sendmessage\n\nSend a cross process message if message channel is connected.\nAvoid [channel closed](https://github.com/joyent/node/blob/cfcb1de130867197cbc9c6012b7e84e08e53d032/lib/child_process.js#L411) error throw out.\n\n## Install\n\n```bash\nnpm install sendmessage --save\n```\n\n## Usage\n\n### master.js\n\n```ts\nimport { fork } from 'node:child_process';\nimport { sendmessage } from 'sendmessage';\n\nconst worker = fork('./worker.js');\n\nsendmessage(worker, { hi: 'this is a message to worker' });\n```\n\n### worker.js\n\n```ts\nimport { sendmessage } from 'sendmessage';\n\nsendmessage(process, { hello: 'this is a message to master' });\n```\n\n## API\n\n### #sendmessage(childProcess, message)\n\nSend a cross process message.\nIf a process is not child process, this will just call `process.emit('message', message)` instead.\n\n- childProcess: child process instance\n- message: the message need to send\n\n```js\nsendmessage(process, { hello: 'this is a message to master' });\n```\n\nYou can switch to `process.emit('message', message)` using `process.env.SENDMESSAGE_ONE_PROCESS`\n\n## License\n\n[MIT](LICENSE)\n\n## Contributors\n\n[![Contributors](https://contrib.rocks/image?repo=node-modules/sendmessage)](https://github.com/node-modules/sendmessage/graphs/contributors)\n\nMade with [contributors-img](https://contrib.rocks).\n","publish_time":1758988139788,"_cnpm_publish_time":1758988139788,"dist-tags":{"latest":"3.0.2"}}