{"name":"sendmessage","version":"1.0.2","keywords":["sendmessage","send","cluster","message","channel closed"],"author":{"url":"http://fengmk2.github.com","name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","_id":"sendmessage@1.0.2","contributors":[{"url":"https://github.com/fengmk2","name":"fengmk2","email":"fengmk2@gmail.com"}],"homepage":"https://github.com/node-modules/sendmessage","bugs":{"url":"https://github.com/node-modules/sendmessage/issues","email":"fengmk2@gmail.com"},"dist":{"shasum":"445e74a695e67a1cb6406a5ae8c4eddfcc946564","tarball":"http://registry-npm.ywwl.com/sendmessage/download/sendmessage-1.0.2.tgz","integrity":"sha512-FnOPK2lekvVACy/hw3QmywHfT7kNjt75wIK9/KZPxY2kM8qU/dndVzh1LPINbF75LVcAF3fU5rU57EHO6D+BSQ==","signatures":[{"sig":"MEUCIFqbzgjoMZXq0D1uyeG8TNKMkPXY+KKhjp7vadzqhMZUAiEAgg1iuZcp4zgiVd8AJTRzAnndqLAsCWWTKM5XyZ0eqaA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":2789,"noattachment":false,"key":"/sendmessage/-/sendmessage-1.0.2.tgz"},"main":"index.js","_from":".","_shasum":"445e74a695e67a1cb6406a5ae8c4eddfcc946564","engines":{"node":">= 0.10.0"},"gitHead":"6943d87c9bec6762fdbb7d1bb42f0126ff52be71","scripts":{"cnpm":"npm install --registry=https://registry.npm.taobao.org","test":"mocha --check-leaks -R spec -t 5000 -r should test/*.test.js","autod":"autod -w --prefix '~'","jshint":"jshint .","test-cov":"node node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- --check-leaks -t 5000 -r should test/*.test.js","test-travis":"node node_modules/.bin/istanbul cover node_modules/.bin/_mocha --report lcovonly -- --check-leaks -t 5000 -r should test/*.test.js","contributors":"contributors -f plain -o AUTHORS"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"repository":{"url":"git://github.com/node-modules/sendmessage.git","web":"https://github.com/node-modules/sendmessage","type":"git"},"_npmVersion":"2.1.6","description":"Send a cross process message if message channel is connected.","directories":{},"_nodeVersion":"0.11.14","dependencies":{},"devDependencies":{"autod":"*","mocha":"*","jshint":"*","should":"*","istanbul":"*","contributors":"*"},"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":1416559284423,"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_cnpm_publish_time":1416559284423,"dist-tags":{"latest":"3.0.2"}}