{"_id":"bellhop","_rev":"25-d6e0dfe45fb9eb68e02593ed62a4b579","name":"bellhop","description":"Pubsub and RPC streams for node.js","dist-tags":{"latest":"0.4.1"},"versions":{"0.0.1":{"name":"bellhop","version":"0.0.1","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Pubsub and RPC streams for node.js","main":"./lib/main","dependencies":{"xfer":"0.2.x"},"scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["pubsub","rpc","hub","bus"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/bellhop/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/bellhop.git"},"readme":"\nDescription\n===========\n\nA node.js module that exposes streams for doing Pubsub and RPC.\n\nSerialization of types unsupported by JSON is also an option and is enabled by default.\nIt should also be noted that properties of \"non-plain objects\" (e.g. Dates, Functions, Errors, RegExps) are not checked for needed serialization.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n============\n\n    npm install bellhop\n\n\nExamples\n========\n\n* Simple RPC (no intermediate medium/stream):\n\n```javascript\nvar RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    RPC_Client = new RPC();\n\nRPC_Server.add(function add(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a + b);\n});\nRPC_Server.add(function serverDate() {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(new Date());\n});\nRPC_Server.add(function customCalc(fn) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(fn());\n});\n\n\nvar add = RPC_Client.makeRemoteFn('add'),\n    serverDate = RPC_Client.makeRemoteFn('serverDate'),\n    customCalc = RPC_Client.makeRemoteFn('customCalc');\n\nadd(5, 5, function(result) {\n  console.log('add() result = ' + result);\n});\nserverDate(function(date) {\n  console.log('serverDate() date UNIX timestamp: ' + date.getTime());\n});\ncustomCalc(function() {\n  console.log('Look at me, I am running on the server!');\n}, function() {\n  console.log('customCalc() Finished executing function on server');\n});\n\n\nRPC_Client.pipe(RPC_Server).pipe(RPC_Client);\n\n\n// Example output:\n//\n// add() result = 10\n// serverDate() date UNIX timestamp: 1383242166000\n// Look at me, I am running on the server!\n// customCalc() Finished executing function on server\n```\n\n* Simple Pubsub (no intermediate medium/stream):\n\n```javascript\nvar Pubsub = require('bellhop').Pubsub;\n\nvar Pubsub1 = new Pubsub(),\n    Pubsub2 = new Pubsub();\n\nPubsub1.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n});\n\nPubsub2.events.emit('today', new Date());\n\nPubsub1.pipe(Pubsub2).pipe(Pubsub1);\n\n\n// Example output:\n//\n// Today is: Thu Oct 31 2013 14:02:00 GMT-0400 (Eastern Daylight Time)\n```\n\n\nAPI\n===\n\nAll types are _Duplex_ streams.\n\nRPC methods\n-----------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new RPC instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n\n* **makeRemoteFn**(< _string_ >remoteFuncName) - _function_ - Returns a function that can be used when calling a particular remote function. This makes things easier than using send() manually. The return value of the returned function is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **send**([< _mixed_ >arg1, ..., < _mixed_ >argn, ]< _string_ >remoteFuncName[, < _function_ >callback]) - _(boolean)_ - Calls the function identified by `remoteFuncName` (with optional arguments). The return value is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **add**(< _function_ >method[, < _string_ >methodName]) - _(void)_ - Adds a function that can be called by others. `methodName` is optional if `method` is a named function, however you can always override the name with `methodName`. The last argument passed to the function is the callback to call in case the other side requested a response. The return value of the callback is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **remove**([< _function_ >method][, < _string_ >methodName]) - _(void)_ - Removes a function previously added via add(). The removal process first checks `methodName`, then `method` for a name, and if those two are not set then *all* instances of that function are removed.\n\n\nPubsub properties\n-----------------\n\n* **events** - _EventEmitter_ - This is the event emitter object used to emit events to others and to receive events from others.\n\nPubsub methods\n--------------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new Pubsub instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/bellhop/issues"},"_id":"bellhop@0.0.1","dist":{"shasum":"8416dc9fa7dcd22f8d6adcd3a3d4b3646a52f636","tarball":"https://registry.npmjs.org/bellhop/-/bellhop-0.0.1.tgz","integrity":"sha512-wsdtSwFrFKdt0XuW+vi/QOV9nKm4qGOov/ofwui5KTWy6A14V1/Yo4rFuOH+OtZbGy4yXIu8oeaSpXYD1fw9zA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDmXB6CBe4VNjlMp4z2AuMbj+udKC8YcHdEuP3EmYUTjgIgEFQsGyRzJ8YJXN7ovhWqewQtCAnyYLjkrMRwlekvOjk="}]},"_from":"https://github.com/mscdex/bellhop/tarball/v0.0.1","_resolved":"https://github.com/mscdex/bellhop/tarball/v0.0.1","_npmVersion":"1.3.11","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.0.2":{"name":"bellhop","version":"0.0.2","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Pubsub and RPC streams for node.js","main":"./lib/main","dependencies":{"xfer":"0.2.x"},"scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["pubsub","rpc","hub","bus"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/bellhop/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/bellhop.git"},"readme":"\nDescription\n===========\n\nA node.js module that exposes streams for doing Pubsub and RPC.\n\nSerialization of types unsupported by JSON is also an option and is enabled by default.\nIt should also be noted that properties of \"non-plain objects\" (e.g. Dates, Functions, Errors, RegExps) are not checked for needed serialization.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n============\n\n    npm install bellhop\n\n\nExamples\n========\n\n* Simple RPC (no intermediate medium/stream):\n\n```javascript\nvar RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    RPC_Client = new RPC();\n\nRPC_Server.add(function add(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a + b);\n});\nRPC_Server.add(function serverDate() {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(new Date());\n});\nRPC_Server.add(function customCalc(fn) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(fn());\n});\n\n\nvar add = RPC_Client.makeRemoteFn('add'),\n    serverDate = RPC_Client.makeRemoteFn('serverDate'),\n    customCalc = RPC_Client.makeRemoteFn('customCalc');\n\nadd(5, 5, function(result) {\n  console.log('add() result = ' + result);\n});\nserverDate(function(date) {\n  console.log('serverDate() date UNIX timestamp: ' + date.getTime());\n});\ncustomCalc(function() {\n  console.log('Look at me, I am running on the server!');\n}, function() {\n  console.log('customCalc() Finished executing function on server');\n});\n\n\nRPC_Client.pipe(RPC_Server).pipe(RPC_Client);\n\n\n// Example output:\n//\n// add() result = 10\n// serverDate() date UNIX timestamp: 1383242166000\n// Look at me, I am running on the server!\n// customCalc() Finished executing function on server\n```\n\n* Simple Pubsub (no intermediate medium/stream):\n\n```javascript\nvar Pubsub = require('bellhop').Pubsub;\n\nvar Pubsub1 = new Pubsub(),\n    Pubsub2 = new Pubsub();\n\nPubsub1.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n});\n\nPubsub2.events.emit('today', new Date());\n\nPubsub1.pipe(Pubsub2).pipe(Pubsub1);\n\n\n// Example output:\n//\n// Today is: Thu Oct 31 2013 14:02:00 GMT-0400 (Eastern Daylight Time)\n```\n\n\nAPI\n===\n\nAll types are _Duplex_ streams.\n\nRPC methods\n-----------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new RPC instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n\n* **makeRemoteFn**(< _string_ >remoteFuncName) - _function_ - Returns a function that can be used when calling a particular remote function. This makes things easier than using send() manually. The return value of the returned function is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **send**([< _mixed_ >arg1, ..., < _mixed_ >argn, ]< _string_ >remoteFuncName[, < _function_ >callback]) - _(boolean)_ - Calls the function identified by `remoteFuncName` (with optional arguments). The return value is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **add**(< _function_ >method[, < _string_ >methodName]) - _(void)_ - Adds a function that can be called by others. `methodName` is optional if `method` is a named function, however you can always override the name with `methodName`. The last argument passed to the function is the callback to call in case the other side requested a response. The return value of the callback is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **remove**([< _function_ >method][, < _string_ >methodName]) - _(void)_ - Removes a function previously added via add(). The removal process first checks `methodName`, then `method` for a name, and if those two are not set then *all* instances of that function are removed.\n\n\nPubsub properties\n-----------------\n\n* **events** - _EventEmitter_ - This is the event emitter object used to emit events to others and to receive events from others.\n\nPubsub methods\n--------------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new Pubsub instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/bellhop/issues"},"_id":"bellhop@0.0.2","dist":{"shasum":"708d2e08b8692a63ae9a76f4868017ea3ac0c390","tarball":"https://registry.npmjs.org/bellhop/-/bellhop-0.0.2.tgz","integrity":"sha512-AtEtK3BDKPlDH+JX8gC/F020MTtVDfY9AFavD4M1+XYhBfwywZw61p/I4yVNel4AmZLTlclVwaoFMV4slqWGUA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCdvmC/6OMhZIa7sqnwxE0scqCdiaJjVa8nH0qfAwXvbgIhAOHE9GWoHfpdMHZP502UwR46qmfm9LEtvXI+zDwB30Wh"}]},"_from":"https://github.com/mscdex/bellhop/tarball/v0.0.2","_resolved":"https://github.com/mscdex/bellhop/tarball/v0.0.2","_npmVersion":"1.3.11","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.0.3":{"name":"bellhop","version":"0.0.3","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Pubsub and RPC streams for node.js","main":"./lib/main","dependencies":{"xfer":"0.2.x"},"scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["pubsub","rpc","hub","bus"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/bellhop/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/bellhop.git"},"readme":"\nDescription\n===========\n\nA node.js module that exposes streams for doing Pubsub and RPC.\n\nSerialization of types unsupported by JSON is also an option and is enabled by default.\nIt should also be noted that properties of \"non-plain objects\" (e.g. Dates, Functions, Errors, RegExps) are not checked for needed serialization.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n============\n\n    npm install bellhop\n\n\nExamples\n========\n\n* Simple RPC (no intermediate medium/stream):\n\n```javascript\nvar RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    RPC_Client = new RPC();\n\nRPC_Server.add(function add(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a + b);\n});\nRPC_Server.add(function serverDate() {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(new Date());\n});\nRPC_Server.add(function customCalc(fn) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(fn());\n});\n\n\nvar add = RPC_Client.makeRemoteFn('add'),\n    serverDate = RPC_Client.makeRemoteFn('serverDate'),\n    customCalc = RPC_Client.makeRemoteFn('customCalc');\n\nadd(5, 5, function(result) {\n  console.log('add() result = ' + result);\n});\nserverDate(function(date) {\n  console.log('serverDate() date UNIX timestamp: ' + date.getTime());\n});\ncustomCalc(function() {\n  console.log('Look at me, I am running on the server!');\n}, function() {\n  console.log('customCalc() Finished executing function on server');\n});\n\n\nRPC_Client.pipe(RPC_Server).pipe(RPC_Client);\n\n\n// Example output:\n//\n// add() result = 10\n// serverDate() date UNIX timestamp: 1383242166000\n// Look at me, I am running on the server!\n// customCalc() Finished executing function on server\n```\n\n* Simple Pubsub (no intermediate medium/stream):\n\n```javascript\nvar Pubsub = require('bellhop').Pubsub;\n\nvar Pubsub1 = new Pubsub(),\n    Pubsub2 = new Pubsub();\n\nPubsub1.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n});\n\nPubsub2.events.emit('today', new Date());\n\nPubsub1.pipe(Pubsub2).pipe(Pubsub1);\n\n\n// Example output:\n//\n// Today is: Thu Oct 31 2013 14:02:00 GMT-0400 (Eastern Daylight Time)\n```\n\n\nAPI\n===\n\nAll types are _Duplex_ streams.\n\nRPC methods\n-----------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new RPC instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n\n* **makeRemoteFn**(< _string_ >remoteFuncName) - _function_ - Returns a function that can be used when calling a particular remote function. This makes things easier than using send() manually. The return value of the returned function is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **send**([< _mixed_ >arg1, ..., < _mixed_ >argn, ]< _string_ >remoteFuncName[, < _function_ >callback]) - _(boolean)_ - Calls the function identified by `remoteFuncName` (with optional arguments). The return value is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **add**(< _function_ >method[, < _string_ >methodName]) - _(void)_ - Adds a function that can be called by others. `methodName` is optional if `method` is a named function, however you can always override the name with `methodName`. The last argument passed to the function is the callback to call in case the other side requested a response. The return value of the callback is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **remove**([< _function_ >method][, < _string_ >methodName]) - _(void)_ - Removes a function previously added via add(). The removal process first checks `methodName`, then `method` for a name, and if those two are not set then *all* instances of that function are removed.\n\n\nPubsub properties\n-----------------\n\n* **events** - _EventEmitter_ - This is the event emitter object used to emit events to others and to receive events from others.\n\nPubsub methods\n--------------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new Pubsub instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/bellhop/issues"},"_id":"bellhop@0.0.3","dist":{"shasum":"721bee3a0fa6a744e659725010af686bb0b0007a","tarball":"https://registry.npmjs.org/bellhop/-/bellhop-0.0.3.tgz","integrity":"sha512-K4PSU/vMwaKdoSbdQl+dpLc5rmY3qzNkSJTlK5PJUyKD8nJFD2p4lwQyUS7j2m9SF+sHG4ZVryK6djibVSPtxg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFWliQFnT8B4FWFIaMnHsv/jSSK3cHXnrddc9UXvM+b8AiEAvCCqQ0QejCu8cqQJdQPmsqmX1lmZXdF+xW9gm5WOlIw="}]},"_from":"https://github.com/mscdex/bellhop/tarball/v0.0.3","_resolved":"https://github.com/mscdex/bellhop/tarball/v0.0.3","_npmVersion":"1.3.11","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.0.4":{"name":"bellhop","version":"0.0.4","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Pubsub and RPC streams for node.js","main":"./lib/main","dependencies":{"xfer":"0.2.x"},"scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["pubsub","rpc","hub","bus"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/bellhop/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/bellhop.git"},"readme":"\nDescription\n===========\n\nA node.js module that exposes streams for doing Pubsub and RPC.\n\nSerialization of types unsupported by JSON is also an option and is enabled by default.\nCurrently properties of \"non-plain objects\" (e.g. Dates, Functions, Errors, RegExps) are not checked for needed serialization. Also, circular references are not detected currently.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n============\n\n    npm install bellhop\n\n\nExamples\n========\n\n* Simple RPC (no intermediate medium/stream):\n\n```javascript\nvar RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    RPC_Client = new RPC();\n\nRPC_Server.add(function add(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a + b);\n});\nRPC_Server.add(function serverDate() {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(new Date());\n});\nRPC_Server.add(function customCalc(fn) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(fn());\n});\n\n\nvar add = RPC_Client.makeRemoteFn('add'),\n    serverDate = RPC_Client.makeRemoteFn('serverDate'),\n    customCalc = RPC_Client.makeRemoteFn('customCalc');\n\nadd(5, 5, function(result) {\n  console.log('add() result = ' + result);\n});\nserverDate(function(date) {\n  console.log('serverDate() date UNIX timestamp: ' + date.getTime());\n});\ncustomCalc(function() {\n  console.log('Look at me, I am running on the server!');\n}, function() {\n  console.log('customCalc() Finished executing function on server');\n});\n\n\nRPC_Client.pipe(RPC_Server).pipe(RPC_Client);\n\n\n// Example output:\n//\n// add() result = 10\n// serverDate() date UNIX timestamp: 1383242166000\n// Look at me, I am running on the server!\n// customCalc() Finished executing function on server\n```\n\n* Simple Pubsub (no intermediate medium/stream):\n\n```javascript\nvar Pubsub = require('bellhop').Pubsub;\n\nvar Pubsub1 = new Pubsub(),\n    Pubsub2 = new Pubsub();\n\nPubsub1.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n});\n\nPubsub2.events.emit('today', new Date());\n\nPubsub1.pipe(Pubsub2).pipe(Pubsub1);\n\n\n// Example output:\n//\n// Today is: Thu Oct 31 2013 14:02:00 GMT-0400 (Eastern Daylight Time)\n```\n\n\nAPI\n===\n\nAll types are _Duplex_ streams.\n\nRPC methods\n-----------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new RPC instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n\n* **makeRemoteFn**(< _string_ >remoteFuncName) - _function_ - Returns a function that can be used when calling a particular remote function. This makes things easier than using send() manually. The return value of the returned function is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **send**([< _mixed_ >arg1, ..., < _mixed_ >argn, ]< _string_ >remoteFuncName[, < _function_ >callback]) - _(boolean)_ - Calls the function identified by `remoteFuncName` (with optional arguments). The return value is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **add**(< _function_ >method[, < _string_ >methodName]) - _(void)_ - Adds a function that can be called by others. `methodName` is optional if `method` is a named function, however you can always override the name with `methodName`. The last argument passed to the function is the callback to call in case the other side requested a response. The return value of the callback is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **remove**([< _function_ >method][, < _string_ >methodName]) - _(void)_ - Removes a function previously added via add(). The removal process first checks `methodName`, then `method` for a name, and if those two are not set then *all* instances of that function are removed.\n\n\nPubsub properties\n-----------------\n\n* **events** - _EventEmitter_ - This is the event emitter object used to emit events to others and to receive events from others.\n\nPubsub (special) events\n-----------------------\n\n* __*__(< _mixed_ >event[, < _mixed_ >arg1, ..., < _mixed_ >argn]) - Emitted for every event for use as a \"catch-all.\"\n\nPubsub methods\n--------------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new Pubsub instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/bellhop/issues"},"_id":"bellhop@0.0.4","dist":{"shasum":"9f45c51ed6a826acee7df6e2e0f2b2a340d5f579","tarball":"https://registry.npmjs.org/bellhop/-/bellhop-0.0.4.tgz","integrity":"sha512-woBQE5lq6Jmwq+/yvqhS81UgW4lAQdZRRwTsjSbnWGFyXjPgsO9FtpPGJ4woFnTPnAQk5CfNzhicjEslwq2hnA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDUxXsvgBsZ2pMFhAOOykJpnNDAiRP/iw9F39a8KlCFnAIgHVodRnQ7KWtym42YaRijuFs80MDLoq1o7sxTgdSBrXc="}]},"_from":"https://github.com/mscdex/bellhop/tarball/v0.0.4","_resolved":"https://github.com/mscdex/bellhop/tarball/v0.0.4","_npmVersion":"1.3.11","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.0.5":{"name":"bellhop","version":"0.0.5","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Pubsub and RPC streams for node.js","main":"./lib/main","dependencies":{"xfer":"0.2.x"},"scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["pubsub","rpc","hub","bus"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/bellhop/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/bellhop.git"},"readme":"\nDescription\n===========\n\nA node.js module that exposes streams for doing Pubsub and RPC.\n\nSerialization of types unsupported by JSON is also an option and is enabled by default.\nCurrently properties of \"non-plain objects\" (e.g. Dates, Functions, Errors, RegExps) are not checked for needed serialization. Also, circular references are not detected currently.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n============\n\n    npm install bellhop\n\n\nExamples\n========\n\n* Simple RPC (no intermediate medium/stream):\n\n```javascript\nvar RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    RPC_Client = new RPC();\n\nRPC_Server.add(function add(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a + b);\n});\nRPC_Server.add(function serverDate() {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(new Date());\n});\nRPC_Server.add(function customCalc(fn) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(fn());\n});\n\n\nvar add = RPC_Client.makeRemoteFn('add'),\n    serverDate = RPC_Client.makeRemoteFn('serverDate'),\n    customCalc = RPC_Client.makeRemoteFn('customCalc');\n\nadd(5, 5, function(result) {\n  console.log('add() result = ' + result);\n});\nserverDate(function(date) {\n  console.log('serverDate() date UNIX timestamp: ' + date.getTime());\n});\ncustomCalc(function() {\n  console.log('Look at me, I am running on the server!');\n}, function() {\n  console.log('customCalc() Finished executing function on server');\n});\n\n\nRPC_Client.pipe(RPC_Server).pipe(RPC_Client);\n\n\n// Example output:\n//\n// add() result = 10\n// serverDate() date UNIX timestamp: 1383242166000\n// Look at me, I am running on the server!\n// customCalc() Finished executing function on server\n```\n\n* Simple Pubsub (no intermediate medium/stream):\n\n```javascript\nvar Pubsub = require('bellhop').Pubsub;\n\nvar Pubsub1 = new Pubsub(),\n    Pubsub2 = new Pubsub();\n\nPubsub1.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n});\n\nPubsub2.events.emit('today', new Date());\n\nPubsub1.pipe(Pubsub2).pipe(Pubsub1);\n\n\n// Example output:\n//\n// Today is: Thu Oct 31 2013 14:02:00 GMT-0400 (Eastern Daylight Time)\n```\n\n\nAPI\n===\n\nAll types are _Duplex_ streams.\n\nRPC methods\n-----------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new RPC instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n\n* **makeRemoteFn**(< _string_ >remoteFuncName) - _function_ - Returns a function that can be used when calling a particular remote function. This makes things easier than using send() manually. The return value of the returned function is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **send**([< _mixed_ >arg1, ..., < _mixed_ >argn, ]< _string_ >remoteFuncName[, < _function_ >callback]) - _(boolean)_ - Calls the function identified by `remoteFuncName` (with optional arguments). The return value is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **add**(< _function_ >method[, < _string_ >methodName]) - _(void)_ - Adds a function that can be called by others. `methodName` is optional if `method` is a named function, however you can always override the name with `methodName`. The last argument passed to the function is the callback to call in case the other side requested a response. The return value of the callback is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **remove**([< _function_ >method][, < _string_ >methodName]) - _(void)_ - Removes a function previously added via add(). The removal process first checks `methodName`, then `method` for a name, and if those two are not set then *all* instances of that function are removed.\n\n\nPubsub properties\n-----------------\n\n* **events** - _EventEmitter_ - This is the event emitter object used to emit events to others and to receive events from others.\n\nPubsub (special) events\n-----------------------\n\n* __*__(< _mixed_ >event[, < _mixed_ >arg1, ..., < _mixed_ >argn]) - Emitted for every event for use as a \"catch-all.\"\n\nPubsub methods\n--------------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new Pubsub instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/bellhop/issues"},"_id":"bellhop@0.0.5","dist":{"shasum":"6afbcfdb8c165c76399b3e69bf500564bde3f3d9","tarball":"https://registry.npmjs.org/bellhop/-/bellhop-0.0.5.tgz","integrity":"sha512-1VK2mKLK3/MAlYPYRMTqldHCSPK4+C3fsJeI4dv2vhMawUjSGQTgVa3dhWhqfUY7FRdm9yRE37N1NxQ7Xyg/fQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCnoCW0PlRK21TJweqwaARkINqJTUbQm+i0V9SLKf9HOgIhAPrZhLnJE/gSd2g18+dirBYYW+f72x7KFMmNkj449+ND"}]},"_from":"https://github.com/mscdex/bellhop/tarball/v0.0.5","_resolved":"https://github.com/mscdex/bellhop/tarball/v0.0.5","_npmVersion":"1.3.11","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.1.0":{"name":"bellhop","version":"0.1.0","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Pubsub and RPC streams for node.js","main":"./lib/main","dependencies":{"xfer":"0.2.x"},"scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["pubsub","rpc","hub","bus"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/bellhop/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/bellhop.git"},"readme":"\nDescription\n===========\n\nA node.js module that exposes streams for doing Pubsub and RPC.\n\nSerialization of types unsupported by JSON is also an option and is enabled by default.\nCurrently properties of \"non-plain objects\" (e.g. Dates, Functions, Errors, RegExps) are not checked for needed serialization. Also, circular references are not detected currently.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n============\n\n    npm install bellhop\n\n\nExamples\n========\n\n* Simple RPC (no intermediate medium/stream):\n\n```javascript\nvar RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    RPC_Client = new RPC();\n\nRPC_Server.add(function add(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a + b);\n});\nRPC_Server.add(function serverDate() {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(new Date());\n});\nRPC_Server.add(function customCalc(fn) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(fn());\n});\n\n\nvar add = RPC_Client.generate('add'),\n    serverDate = RPC_Client.generate('serverDate'),\n    customCalc = RPC_Client.generate('customCalc');\n\nadd(5, 5, function(result) {\n  console.log('add() result = ' + result);\n});\nserverDate(function(date) {\n  console.log('serverDate() date UNIX timestamp: ' + date.getTime());\n});\ncustomCalc(function() {\n  console.log('Look at me, I am running on the server!');\n}, function() {\n  console.log('customCalc() Finished executing function on server');\n});\n\n\nRPC_Client.pipe(RPC_Server).pipe(RPC_Client);\n\n\n// Example output:\n//\n// add() result = 10\n// serverDate() date UNIX timestamp: 1383242166000\n// Look at me, I am running on the server!\n// customCalc() Finished executing function on server\n```\n\n* Simple Pubsub (no intermediate medium/stream):\n\n```javascript\nvar Pubsub = require('bellhop').Pubsub;\n\nvar Pubsub1 = new Pubsub(),\n    Pubsub2 = new Pubsub();\n\nPubsub1.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n});\n\nPubsub2.events.emit('today', new Date());\n\nPubsub1.pipe(Pubsub2).pipe(Pubsub1);\n\n\n// Example output:\n//\n// Today is: Thu Oct 31 2013 14:02:00 GMT-0400 (Eastern Daylight Time)\n```\n\n\nAPI\n===\n\nAll types are _Duplex_ streams.\n\nRPC methods\n-----------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new RPC instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n\n* **generate**(< _string_ >remoteFuncName) - _function_ - Returns a function that can be used when calling a particular remote function. This makes things easier than using send() manually. The return value of the returned function is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **send**([< _mixed_ >arg1, ..., < _mixed_ >argn, ]< _string_ >remoteFuncName[, < _function_ >callback]) - _(boolean)_ - Calls the function identified by `remoteFuncName` (with optional arguments). The return value is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **add**(< _function_ >method[, < _string_ >methodName]) - _(void)_ - Adds a function that can be called by others. `methodName` is optional if `method` is a named function, however you can always override the name with `methodName`. The last argument passed to the function is the callback to call in case the other side requested a response. The return value of the callback is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **remove**([< _function_ >method][, < _string_ >methodName]) - _(void)_ - Removes a function previously added via add(). The removal process first checks `methodName`, then `method` for a name, and if those two are not set then *all* instances of that function are removed.\n\n\nPubsub properties\n-----------------\n\n* **events** - _EventEmitter_ - This is the event emitter object used to emit events to others and to receive events from others.\n\nPubsub (special) events\n-----------------------\n\n* __*__(< _mixed_ >event[, < _mixed_ >arg1, ..., < _mixed_ >argn]) - Emitted for every event for use as a \"catch-all.\"\n\nPubsub methods\n--------------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new Pubsub instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/bellhop/issues"},"_id":"bellhop@0.1.0","dist":{"shasum":"21a4c1b211680f07eaebdff8fb5159792f564cee","tarball":"https://registry.npmjs.org/bellhop/-/bellhop-0.1.0.tgz","integrity":"sha512-YNXUjnOwpaS6lRMxGAElGyqyLXCi6wal+xrbGP0HsYtd2Z+UhqJaIEjwSR9WiDs8HhjJPkHHybdLW7PtZXErpQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDG967Iz+j5H8bf67AgSltsYOXzol+Tt4ni8cE0eJYa2gIhAMUk4HfRYiZVCFIzSrVIOihRJ3a+zZeGWthdUumVyPR4"}]},"_from":"https://github.com/mscdex/bellhop/tarball/v0.1.0","_resolved":"https://github.com/mscdex/bellhop/tarball/v0.1.0","_npmVersion":"1.3.11","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.2.0":{"name":"bellhop","version":"0.2.0","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Pubsub and RPC streams for node.js","main":"./lib/main","dependencies":{"xfer":"0.2.x"},"scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["pubsub","rpc","hub","bus"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/bellhop/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/bellhop.git"},"readme":"\nDescription\n===========\n\nA node.js module that exposes streams for doing Pubsub and RPC.\n\nNotes:\n\n * Serialization of types unsupported by JSON is an option and is enabled by default.\n \n * Properties of \"non-plain objects\" (e.g. Dates, Functions, Errors, RegExps) are not checked for needed serialization.\n\n * Circular references are not detected.\n\n * RPC-specific:\n\n     * Callback functions follow the error-first argument pattern. Any arguments after the error argument are values returned by the other side.\n\n     * All functions returned by `generate()` will assume that a function passed as the last argument will be a callback to be executed when the server responds. If you need to pass a function to the other side, make sure a non-function value separates it and the optional callback **OR** you can use `send()` directly instead. Examples:\n\n        ```javascript\n        // ....\n        var map = RPC_Client.generate('map');\n\n        // no callback/response (THIS IS WRONG, the mapper function will not be sent to the other side and will be used as a callback instead)\n        map([0, 1, 2, 3, 4], function(n) { return n * 2; });\n\n        // no callback/response\n        map(function(n) { return n * 2; }, [0, 1, 2, 3, 4]);\n\n        // callback/response requested\n        map(function(n) { return n * 2; }, [0, 1, 2, 3, 4], function(result) { console.log('Result: ' + result); });\n\n        // OR always use `send()` directly if you want/need the mapper function to always be the second argument:\n\n        // no callback/response\n        RPC_Client.send([0, 1, 2, 3, 4], function(n) { return n * 2; }, 'map');\n\n        // callback/response requested\n        RPC_Client.send([0, 1, 2, 3, 4], function(n) { return n * 2; }, 'map', function(result) {\n          console.log('Result: ' + result);\n        });\n        ```\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n============\n\n    npm install bellhop\n\n\nExamples\n========\n\n* Simple RPC (no intermediate medium/stream):\n\n```javascript\nvar RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    RPC_Client = new RPC();\n\nRPC_Server.add(function add(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a + b);\n});\nRPC_Server.add(function serverDate() {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(new Date());\n});\nRPC_Server.add(function customCalc(fn) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(fn());\n});\n\n\nvar add = RPC_Client.generate('add'),\n    serverDate = RPC_Client.generate('serverDate'),\n    customCalc = RPC_Client.generate('customCalc');\n\nadd(5, 5, function(err, result) {\n  console.log('add() result = ' + result);\n});\nserverDate(function(err, date) {\n  console.log('serverDate() date UNIX timestamp: ' + date.getTime());\n});\ncustomCalc(function() {\n  console.log('Look at me, I am running on the server!');\n}, function(err) {\n  console.log('customCalc() Finished executing function on server');\n});\n\n\nRPC_Client.pipe(RPC_Server).pipe(RPC_Client);\n\n\n// Example output:\n//\n// add() result = 10\n// serverDate() date UNIX timestamp: 1383242166000\n// Look at me, I am running on the server!\n// customCalc() Finished executing function on server\n```\n\n* Simple Pubsub (no intermediate medium/stream):\n\n```javascript\nvar Pubsub = require('bellhop').Pubsub;\n\nvar Pubsub1 = new Pubsub(),\n    Pubsub2 = new Pubsub();\n\nPubsub1.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n});\n\nPubsub2.events.emit('today', new Date());\n\nPubsub1.pipe(Pubsub2).pipe(Pubsub1);\n\n\n// Example output:\n//\n// Today is: Thu Oct 31 2013 14:02:00 GMT-0400 (Eastern Daylight Time)\n```\n\n\nAPI\n===\n\nAll types are _Duplex_ streams.\n\nRPC methods\n-----------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new RPC instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **ignoreInvalidCall** - _boolean_ - Do not send error responses to incoming function call requests for invalid methods (Default: false).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n\n* **generate**(< _string_ >remoteFuncName) - _function_ - Returns a function that can be used when calling a particular remote function. This makes things easier than using send() manually. The return value of the returned function is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **send**([< _mixed_ >arg1, ..., < _mixed_ >argn, ]< _string_ >remoteFuncName[, < _function_ >callback]) - _(boolean)_ - Calls the function identified by `remoteFuncName` (with optional arguments). The return value is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **add**(< _function_ >method[, < _string_ >methodName]) - _(void)_ - Adds a function that can be called by others. `methodName` is optional if `method` is a named function, however you can always override the name with `methodName`. The last argument passed to the function is the callback to call in case the other side requested a response. The return value of the callback is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **remove**([< _function_ >method][, < _string_ >methodName]) - _(void)_ - Removes a function previously added via add(). The removal process first checks `methodName`, then `method` for a name, and if those two are not set then *all* instances of that function are removed.\n\n\nPubsub properties\n-----------------\n\n* **events** - _EventEmitter_ - This is the event emitter object used to emit events to others and to receive events from others.\n\nPubsub (special) events\n-----------------------\n\n* __*__(< _mixed_ >event[, < _mixed_ >arg1, ..., < _mixed_ >argn]) - Emitted for every event for use as a \"catch-all.\"\n\nPubsub methods\n--------------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new Pubsub instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/bellhop/issues"},"_id":"bellhop@0.2.0","dist":{"shasum":"d1c0e69adc68c5163c8e4f7e1cc17912fbf58abe","tarball":"https://registry.npmjs.org/bellhop/-/bellhop-0.2.0.tgz","integrity":"sha512-xE0lpltgEthLbUYdT7ik0elcXOCIkp/dRRXMFbs16QEcTn+2eUyl7DUBwllHXIHBN3F09vFyn6qoZyhTGZ89+A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDHtUKi8KyYCzgQYAQEALeee17rKP0/ziUI5AOZwN6mNAIhAODdayANUFA7YrdQewA6ndK5aF86pckUqwNbtZp1vhJT"}]},"_from":"https://github.com/mscdex/bellhop/tarball/v0.2.0","_resolved":"https://github.com/mscdex/bellhop/tarball/v0.2.0","_npmVersion":"1.3.11","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.3.0":{"name":"bellhop","version":"0.3.0","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Pubsub and RPC streams for node.js","main":"./lib/main","scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["pubsub","rpc","hub","bus"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/bellhop/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/bellhop.git"},"readme":"\nDescription\n===========\n\nA node.js module that exposes streams for doing Pubsub and RPC.\n\nNotes:\n\n * Serialization of types unsupported by JSON is an option and is enabled by default.\n \n * Properties of \"non-plain objects\" (e.g. Dates, Functions, Errors, RegExps) are not checked for needed serialization.\n\n * Circular references are not detected.\n\n * RPC-specific:\n\n     * Callback functions follow the error-first argument pattern. Any arguments after the error argument are values returned by the other side.\n\n     * All functions returned by `generate()` will assume that a function passed as the last argument will be a callback to be executed when the server responds. If you need to pass a function to the other side, make sure a non-function value separates it and the optional callback **OR** you can use `send()` directly instead. Examples:\n\n        ```javascript\n        // ....\n        var map = RPC_Client.generate('map');\n\n        // no callback/response (THIS IS WRONG, the mapper function will not be sent to the other side and will be used as a callback instead)\n        map([0, 1, 2, 3, 4], function(n) { return n * 2; });\n\n        // no callback/response\n        map(function(n) { return n * 2; }, [0, 1, 2, 3, 4]);\n\n        // callback/response requested\n        map(function(n) { return n * 2; }, [0, 1, 2, 3, 4], function(result) { console.log('Result: ' + result); });\n\n        // OR always use `send()` directly if you want/need the mapper function to always be the second argument:\n\n        // no callback/response\n        RPC_Client.send([0, 1, 2, 3, 4], function(n) { return n * 2; }, 'map');\n\n        // callback/response requested\n        RPC_Client.send([0, 1, 2, 3, 4], function(n) { return n * 2; }, 'map', function(result) {\n          console.log('Result: ' + result);\n        });\n        ```\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n============\n\n    npm install bellhop\n\n\nExamples\n========\n\n* Simple RPC (no intermediate medium/stream):\n\n```javascript\nvar RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    RPC_Client = new RPC();\n\nRPC_Server.add(function add(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a + b);\n});\nRPC_Server.add(function serverDate() {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(new Date());\n});\nRPC_Server.add(function customCalc(fn) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(fn());\n});\n\n\nvar add = RPC_Client.generate('add'),\n    serverDate = RPC_Client.generate('serverDate'),\n    customCalc = RPC_Client.generate('customCalc');\n\nadd(5, 5, function(err, result) {\n  console.log('add() result = ' + result);\n});\nserverDate(function(err, date) {\n  console.log('serverDate() date UNIX timestamp: ' + date.getTime());\n});\ncustomCalc(function() {\n  console.log('Look at me, I am running on the server!');\n}, function(err) {\n  console.log('customCalc() Finished executing function on server');\n});\n\n\nRPC_Client.pipe(RPC_Server).pipe(RPC_Client);\n\n\n// Example output:\n//\n// add() result = 10\n// serverDate() date UNIX timestamp: 1383242166000\n// Look at me, I am running on the server!\n// customCalc() Finished executing function on server\n```\n\n* RPC over HTTP (10 simultaneous requests to same RPC server stream using [Conveyor](https://github.com/mscdex/conveyor)):\n\n```javascript\nvar http = require('http');\nvar Conveyor = require('conveyor'),\n    RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    c = new Conveyor(RPC_Server);\n\nRPC_Server.add(function multiply(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a * b);\n});\n\nvar TOTAL = 10, count = 0;\n\nhttp.createServer(function(req, res) {\n  if (++count === TOTAL)\n    this.close();\n  c.push(req, res);\n}).listen(8080, function() {\n  console.log('HTTP RPC server listening');\n\n  for (var i = 0; i < TOTAL; ++i) {\n    (function(n) {\n      var RPC_Client = new RPC(),\n          multiply = RPC_Client.generate('multiply'),\n          req = http.request({\n            host: '127.0.0.1',\n            port: 8080,\n            method: 'POST'\n          }, function(res) {\n            res.pipe(RPC_Client, { end: false });\n          });\n      RPC_Client.pipe(req);\n      multiply(2, n, function(err, result) {\n        console.log('Result = ' + result);\n        req.end();\n      });\n    })(i);\n  }\n});\n\n// Output:\n//\n// HTTP RPC server listening\n// Result = 0\n// Result = 2\n// Result = 4\n// Result = 6\n// Result = 8\n// Result = 10\n// Result = 12\n// Result = 14\n// Result = 16\n// Result = 18\n```\n\n* Simple Pubsub (no intermediate medium/stream):\n\n```javascript\nvar Pubsub = require('bellhop').Pubsub;\n\nvar Pubsub1 = new Pubsub(),\n    Pubsub2 = new Pubsub();\n\nPubsub1.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n});\n\nPubsub2.events.emit('today', new Date());\n\nPubsub1.pipe(Pubsub2).pipe(Pubsub1);\n\n\n// Example output:\n//\n// Today is: Thu Oct 31 2013 14:02:00 GMT-0400 (Eastern Daylight Time)\n```\n\n\nAPI\n===\n\nAll types are _Duplex_ streams.\n\nRPC methods\n-----------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new RPC instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **ignoreInvalidCall** - _boolean_ - Do not send error responses to incoming function call requests for invalid methods (Default: false).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n* **generate**(< _string_ >remoteFuncName) - _function_ - Returns a function that can be used when calling a particular remote function. This makes things easier than using send() manually. The return value of the returned function is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **send**([< _mixed_ >arg1, ..., < _mixed_ >argn, ]< _string_ >remoteFuncName[, < _function_ >callback]) - _(boolean)_ - Calls the function identified by `remoteFuncName` (with optional arguments). The return value is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **add**(< _function_ >method[, < _string_ >methodName]) - _(void)_ - Adds a function that can be called by others. `methodName` is optional if `method` is a named function, however you can always override the name with `methodName`. The last argument passed to the function is the callback to call in case the other side requested a response. The return value of the callback is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **remove**([< _function_ >method][, < _string_ >methodName]) - _(void)_ - Removes a function previously added via add(). The removal process first checks `methodName`, then `method` for a name, and if those two are not set then *all* instances of that function are removed.\n\n\nPubsub properties\n-----------------\n\n* **events** - _EventEmitter_ - This is the event emitter object used to emit events to others and to receive events from others.\n\nPubsub (special) events\n-----------------------\n\n* __*__(< _mixed_ >event[, < _mixed_ >arg1, ..., < _mixed_ >argn]) - Emitted for every event for use as a \"catch-all.\"\n\nPubsub methods\n--------------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new Pubsub instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/bellhop/issues"},"_id":"bellhop@0.3.0","dist":{"shasum":"b0e07b256ead89118cc511832a35bb2b21f9abf1","tarball":"https://registry.npmjs.org/bellhop/-/bellhop-0.3.0.tgz","integrity":"sha512-vVKwJb1tLUqqr+WYNlxYd1vbkB5SZVhAEBpmFgodaLu47O+168UHndqHbBba0+wUYiRJkyl18xIjJ2ogTSx2jg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCNlYNEBjdit0nxOiirjduoivgOGXak4Aue6EPHcdXo9AIgYG1jFmKKrLbRDm7krq1FyIJZPYcFeSiJD3r46H5YrjI="}]},"_from":"https://github.com/mscdex/bellhop/tarball/v0.3.0","_resolved":"https://github.com/mscdex/bellhop/tarball/v0.3.0","_npmVersion":"1.3.11","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.3.1":{"name":"bellhop","version":"0.3.1","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Pubsub and RPC streams for node.js","main":"./lib/main","scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["pubsub","rpc","hub","bus","streams","streams2"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/bellhop/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/bellhop.git"},"readme":"\nDescription\n===========\n\nA node.js module that exposes streams for doing Pubsub and RPC.\n\nNotes:\n\n * Serialization of types unsupported by JSON is an option and is enabled by default.\n \n * Properties of \"non-plain objects\" (e.g. Dates, Functions, Errors, RegExps) are not checked for needed serialization.\n\n * Circular references are not detected.\n\n * RPC-specific:\n\n     * Callback functions follow the error-first argument pattern. Any arguments after the error argument are values returned by the other side.\n\n     * All functions returned by `generate()` will assume that a function passed as the last argument will be a callback to be executed when the server responds. If you need to pass a function to the other side, make sure a non-function value separates it and the optional callback **OR** you can use `send()` directly instead. Examples:\n\n        ```javascript\n        // ....\n        var map = RPC_Client.generate('map');\n\n        // no callback/response (THIS IS WRONG, the mapper function will not be sent to the other side and will be used as a callback instead)\n        map([0, 1, 2, 3, 4], function(n) { return n * 2; });\n\n        // no callback/response\n        map(function(n) { return n * 2; }, [0, 1, 2, 3, 4]);\n\n        // callback/response requested\n        map(function(n) { return n * 2; }, [0, 1, 2, 3, 4], function(result) { console.log('Result: ' + result); });\n\n        // OR always use `send()` directly if you want/need the mapper function to always be the second argument:\n\n        // no callback/response\n        RPC_Client.send([0, 1, 2, 3, 4], function(n) { return n * 2; }, 'map');\n\n        // callback/response requested\n        RPC_Client.send([0, 1, 2, 3, 4], function(n) { return n * 2; }, 'map', function(result) {\n          console.log('Result: ' + result);\n        });\n        ```\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n============\n\n    npm install bellhop\n\n\nExamples\n========\n\n* Simple RPC (no intermediate medium/stream):\n\n```javascript\nvar RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    RPC_Client = new RPC();\n\nRPC_Server.add(function add(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a + b);\n});\nRPC_Server.add(function serverDate() {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(new Date());\n});\nRPC_Server.add(function customCalc(fn) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(fn());\n});\n\n\nvar add = RPC_Client.generate('add'),\n    serverDate = RPC_Client.generate('serverDate'),\n    customCalc = RPC_Client.generate('customCalc');\n\nadd(5, 5, function(err, result) {\n  console.log('add() result = ' + result);\n});\nserverDate(function(err, date) {\n  console.log('serverDate() date UNIX timestamp: ' + date.getTime());\n});\ncustomCalc(function() {\n  console.log('Look at me, I am running on the server!');\n}, function(err) {\n  console.log('customCalc() Finished executing function on server');\n});\n\n\nRPC_Client.pipe(RPC_Server).pipe(RPC_Client);\n\n\n// Example output:\n//\n// add() result = 10\n// serverDate() date UNIX timestamp: 1383242166000\n// Look at me, I am running on the server!\n// customCalc() Finished executing function on server\n```\n\n* RPC over HTTP (10 simultaneous requests to same RPC server stream using [Conveyor](https://github.com/mscdex/conveyor)):\n\n```javascript\nvar http = require('http');\nvar Conveyor = require('conveyor'),\n    RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    c = new Conveyor(RPC_Server);\n\nRPC_Server.add(function multiply(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a * b);\n});\n\nvar TOTAL = 10, count = 0;\n\nhttp.createServer(function(req, res) {\n  if (++count === TOTAL)\n    this.close();\n  c.push(req, res);\n}).listen(8080, function() {\n  console.log('HTTP RPC server listening');\n\n  for (var i = 0; i < TOTAL; ++i) {\n    (function(n) {\n      var RPC_Client = new RPC(),\n          multiply = RPC_Client.generate('multiply'),\n          req = http.request({\n            host: '127.0.0.1',\n            port: 8080,\n            method: 'POST'\n          }, function(res) {\n            res.pipe(RPC_Client, { end: false });\n          });\n      RPC_Client.pipe(req);\n      multiply(2, n, function(err, result) {\n        console.log('Result = ' + result);\n        req.end();\n      });\n    })(i);\n  }\n});\n\n// Output:\n//\n// HTTP RPC server listening\n// Result = 0\n// Result = 2\n// Result = 4\n// Result = 6\n// Result = 8\n// Result = 10\n// Result = 12\n// Result = 14\n// Result = 16\n// Result = 18\n```\n\n* Simple Pubsub (no intermediate medium/stream):\n\n```javascript\nvar Pubsub = require('bellhop').Pubsub;\n\nvar Pubsub1 = new Pubsub(),\n    Pubsub2 = new Pubsub();\n\nPubsub1.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n});\n\nPubsub2.events.emit('today', new Date());\n\nPubsub1.pipe(Pubsub2).pipe(Pubsub1);\n\n// Example output:\n//\n// Today is: Thu Oct 31 2013 14:02:00 GMT-0400 (Eastern Daylight Time)\n```\n\n* Simple Pubsub over TCP:\n\n```javascript\nvar net = require('net');\n\nvar Pubsub = require('bellhop').Pubsub;\n\nvar PubsubRecvr = new Pubsub(),\n    PubsubSender = new Pubsub();\n\nnet.createServer(function(sock) {\n  this.close();\n  PubsubSender.pipe(sock);\n  PubsubSender.events.emit('today', new Date());\n}).listen(9000, '127.0.0.1');\n\nvar sock = new net.Socket();\nsock.pipe(PubsubRecvr);\nPubsubRecvr.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n  sock.end();\n});\nsock.connect(9000, '127.0.0.1');\n\n// Example output:\n//\n// Today is: Thu Nov 14 2013 07:52:01 GMT-0500 (Eastern Standard Time)\n```\n\n\nAPI\n===\n\nAll types are _Duplex_ streams.\n\nRPC methods\n-----------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new RPC instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **ignoreInvalidCall** - _boolean_ - Do not send error responses to incoming function call requests for invalid methods (Default: false).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n* **generate**(< _string_ >remoteFuncName) - _function_ - Returns a function that can be used when calling a particular remote function. This makes things easier than using send() manually. The return value of the returned function is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **send**([< _mixed_ >arg1, ..., < _mixed_ >argn, ]< _string_ >remoteFuncName[, < _function_ >callback]) - _(boolean)_ - Calls the function identified by `remoteFuncName` (with optional arguments). The return value is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **add**(< _function_ >method[, < _string_ >methodName]) - _(void)_ - Adds a function that can be called by others. `methodName` is optional if `method` is a named function, however you can always override the name with `methodName`. The last argument passed to the function is the callback to call in case the other side requested a response. The return value of the callback is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **remove**([< _function_ >method][, < _string_ >methodName]) - _(void)_ - Removes a function previously added via add(). The removal process first checks `methodName`, then `method` for a name, and if those two are not set then *all* instances of that function are removed.\n\n\nPubsub properties\n-----------------\n\n* **events** - _EventEmitter_ - This is the event emitter object used to emit events to others and to receive events from others.\n\nPubsub (special) events\n-----------------------\n\n* __*__(< _mixed_ >event[, < _mixed_ >arg1, ..., < _mixed_ >argn]) - Emitted for every event for use as a \"catch-all.\"\n\nPubsub methods\n--------------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new Pubsub instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/bellhop/issues"},"homepage":"https://github.com/mscdex/bellhop","_id":"bellhop@0.3.1","dist":{"shasum":"4efff13031a829d4d3a4dfc601db92cf489f5e74","tarball":"https://registry.npmjs.org/bellhop/-/bellhop-0.3.1.tgz","integrity":"sha512-g+wQ5GUvkxhZ3KJZVyl9YqtWLT+1dROExW7Zia76i45zKWqIk2hlqomMKiM7MQzqAQcnarfpxXc4BKp7n4wiLQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIATJ7k/vGYl2BGk70RP2Di6lIpSKaApTi4d9qSuf9vFbAiEA9jpX6jaWsbZuUdX97TrvxpB9oPd22ve/XJKgKeHz9Fw="}]},"_from":"https://github.com/mscdex/bellhop/tarball/v0.3.1","_resolved":"https://github.com/mscdex/bellhop/tarball/v0.3.1","_npmVersion":"1.3.14","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.4.0":{"name":"bellhop","version":"0.4.0","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Pubsub and RPC streams for node.js","main":"./lib/main","scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["pubsub","rpc","hub","bus","streams","streams2"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/bellhop/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/bellhop.git"},"readme":"\nDescription\n===========\n\nA node.js module that exposes streams for doing Pubsub and RPC.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n============\n\n    npm install bellhop\n\n\nExamples\n========\n\n* Simple RPC (no intermediate medium/stream):\n\n```javascript\nvar RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    RPC_Client = new RPC();\n\nRPC_Server.add(function add(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a + b);\n});\nRPC_Server.add(function serverDate() {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(new Date());\n});\nRPC_Server.add(function customCalc(fn) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(fn());\n});\n\n\nvar add = RPC_Client.generate('add'),\n    serverDate = RPC_Client.generate('serverDate'),\n    customCalc = RPC_Client.generate('customCalc');\n\nadd(5, 5, function(err, result) {\n  console.log('add() result = ' + result);\n});\nserverDate(function(err, date) {\n  console.log('serverDate() date UNIX timestamp: ' + date.getTime());\n});\ncustomCalc(function() {\n  console.log('Look at me, I am running on the server!');\n}, function(err) {\n  console.log('customCalc() Finished executing function on server');\n});\n\n\nRPC_Client.pipe(RPC_Server).pipe(RPC_Client);\n\n\n// Example output:\n//\n// add() result = 10\n// serverDate() date UNIX timestamp: 1383242166000\n// Look at me, I am running on the server!\n// customCalc() Finished executing function on server\n```\n\n* RPC over HTTP (10 simultaneous requests to same RPC server stream using [Conveyor](https://github.com/mscdex/conveyor)):\n\n```javascript\nvar http = require('http');\nvar Conveyor = require('conveyor'),\n    RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    c = new Conveyor(RPC_Server);\n\nRPC_Server.add(function multiply(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a * b);\n});\n\nvar TOTAL = 10, count = 0;\n\nhttp.createServer(function(req, res) {\n  if (++count === TOTAL)\n    this.close();\n  c.push(req, res);\n}).listen(8080, function() {\n  console.log('HTTP RPC server listening');\n\n  for (var i = 0; i < TOTAL; ++i) {\n    (function(n) {\n      var RPC_Client = new RPC(),\n          multiply = RPC_Client.generate('multiply'),\n          req = http.request({\n            host: '127.0.0.1',\n            port: 8080,\n            method: 'POST'\n          }, function(res) {\n            res.pipe(RPC_Client, { end: false });\n          });\n      RPC_Client.pipe(req);\n      multiply(2, n, function(err, result) {\n        console.log('Result = ' + result);\n        req.end();\n      });\n    })(i);\n  }\n});\n\n// Output:\n//\n// HTTP RPC server listening\n// Result = 0\n// Result = 2\n// Result = 4\n// Result = 6\n// Result = 8\n// Result = 10\n// Result = 12\n// Result = 14\n// Result = 16\n// Result = 18\n```\n\n* Simple Pubsub (no intermediate medium/stream):\n\n```javascript\nvar Pubsub = require('bellhop').Pubsub;\n\nvar Pubsub1 = new Pubsub(),\n    Pubsub2 = new Pubsub();\n\nPubsub1.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n});\n\nPubsub2.events.emit('today', new Date());\n\nPubsub1.pipe(Pubsub2).pipe(Pubsub1);\n\n// Example output:\n//\n// Today is: Thu Oct 31 2013 14:02:00 GMT-0400 (Eastern Daylight Time)\n```\n\n* Simple Pubsub over TCP:\n\n```javascript\nvar net = require('net');\n\nvar Pubsub = require('bellhop').Pubsub;\n\nvar PubsubRecvr = new Pubsub(),\n    PubsubSender = new Pubsub();\n\nnet.createServer(function(sock) {\n  this.close();\n  PubsubSender.pipe(sock);\n  PubsubSender.events.emit('today', new Date());\n}).listen(9000, '127.0.0.1');\n\nvar sock = new net.Socket();\nsock.pipe(PubsubRecvr);\nPubsubRecvr.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n  sock.end();\n});\nsock.connect(9000, '127.0.0.1');\n\n// Example output:\n//\n// Today is: Thu Nov 14 2013 07:52:01 GMT-0500 (Eastern Standard Time)\n```\n\n\nBenchmarks\n==========\n\nBenchmarks can be found in `bench/`.\n\nPubsub benchmark (as of 11/14/2013) for Core i7-3770k, Windows 7 x64, node v0.10.22:\n\n```\n50000 events (no args): 327ms\n50000 events (3 short strings): 389ms\n50000 events (3 longer strings): 433ms\n50000 events (3 regexps): 654ms\n50000 events (3 functions): 874ms\n50000 events (5 numeric values): 470ms\n```\n\n\nAPI\n===\n\nAll types are _Duplex_ streams.\n\nRPC methods\n-----------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new RPC instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **ignoreInvalidCall** - _boolean_ - Do not send error responses to incoming function call requests for invalid methods (Default: false).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n* **generate**(< _string_ >remoteFuncName) - _function_ - Returns a function that can be used when calling a particular remote function. This makes things easier than using send() manually. The return value of the returned function is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **send**([< _mixed_ >arg1, ..., < _mixed_ >argn, ]< _string_ >remoteFuncName[, < _function_ >callback]) - _(boolean)_ - Calls the function identified by `remoteFuncName` (with optional arguments). The return value is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **add**(< _function_ >method[, < _string_ >methodName]) - _(void)_ - Adds a function that can be called by others. `methodName` is optional if `method` is a named function, however you can always override the name with `methodName`. The last argument passed to the function is the callback to call in case the other side requested a response. The return value of the callback is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **remove**([< _function_ >method][, < _string_ >methodName]) - _(void)_ - Removes a function previously added via add(). The removal process first checks `methodName`, then `method` for a name, and if those two are not set then *all* instances of that function are removed.\n\n\nPubsub properties\n-----------------\n\n* **events** - _EventEmitter_ - This is the event emitter object used to emit events to others and to receive events from others.\n\nPubsub (special) events\n-----------------------\n\n* __*__(< _mixed_ >event[, < _mixed_ >arg1, ..., < _mixed_ >argn]) - Emitted for every event for use as a \"catch-all.\"\n\nPubsub methods\n--------------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new Pubsub instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n\nNotes\n=====\n\n* Serialization of types unsupported by JSON is an option and is enabled by default.\n\n* Properties of \"non-plain objects\" (e.g. Dates, Functions, Errors, RegExps) are not checked for needed serialization.\n\n* Circular references are not detected.\n\n* RPC-specific:\n\n   * Callback functions follow the error-first argument pattern. Any arguments after the error argument are values returned by the other side.\n\n   * All functions returned by `generate()` will assume that a function passed as the last argument will be a callback to be executed when the server responds. If you need to pass a function to the other side, make sure a non-function value separates it and the optional callback **OR** you can use `send()` directly instead. Examples:\n\n      ```javascript\n      // ....\n      var map = RPC_Client.generate('map');\n\n      // no callback/response (THIS IS WRONG, the mapper function will not be sent to the other side and will be used as a callback instead)\n      map([0, 1, 2, 3, 4], function(n) { return n * 2; });\n\n      // no callback/response\n      map(function(n) { return n * 2; }, [0, 1, 2, 3, 4]);\n\n      // callback/response requested\n      map(function(n) { return n * 2; }, [0, 1, 2, 3, 4], function(result) { console.log('Result: ' + result); });\n\n      // OR always use `send()` directly if you want/need the mapper function to always be the second argument:\n\n      // no callback/response\n      RPC_Client.send([0, 1, 2, 3, 4], function(n) { return n * 2; }, 'map');\n\n      // callback/response requested\n      RPC_Client.send([0, 1, 2, 3, 4], function(n) { return n * 2; }, 'map', function(result) {\n        console.log('Result: ' + result);\n      });\n      ```","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/bellhop/issues"},"homepage":"https://github.com/mscdex/bellhop","_id":"bellhop@0.4.0","dist":{"shasum":"0661058b74ea536b638e65ec7a6e7212750920cb","tarball":"https://registry.npmjs.org/bellhop/-/bellhop-0.4.0.tgz","integrity":"sha512-sYRnesjEgfS1ZoEQXgX4WdC1q0aGLRnTVAFhrqERc1TYLQ2yd4k5BQIo+JALmJEgNbSh1Pf7gC+T4AgUlp+Nwg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCl5OIIB7vtHBgLKHutnveTQeiXBBgSIShvl72/Xx71iAIgeF93bL1g2lfpT0B5J4/QelDWSDKAXSfbS5Y2dz2YVEA="}]},"_from":"https://github.com/mscdex/bellhop/tarball/v0.4.0","_resolved":"https://github.com/mscdex/bellhop/tarball/v0.4.0","_npmVersion":"1.3.14","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]},"0.4.1":{"name":"bellhop","version":"0.4.1","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"Pubsub and RPC streams for node.js","main":"./lib/main","scripts":{"test":"node test/test.js"},"engines":{"node":">=0.10.0"},"keywords":["pubsub","rpc","hub","bus","streams","streams2"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/bellhop/raw/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/mscdex/bellhop.git"},"readme":"\nDescription\n===========\n\nA node.js module that exposes streams for doing Pubsub and RPC.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n============\n\n    npm install bellhop\n\n\nExamples\n========\n\n* Simple RPC (no intermediate medium/stream):\n\n```javascript\nvar RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    RPC_Client = new RPC();\n\nRPC_Server.add(function add(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a + b);\n});\nRPC_Server.add(function serverDate() {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(new Date());\n});\nRPC_Server.add(function customCalc(fn) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(fn());\n});\n\n\nvar add = RPC_Client.generate('add'),\n    serverDate = RPC_Client.generate('serverDate'),\n    customCalc = RPC_Client.generate('customCalc');\n\nadd(5, 5, function(err, result) {\n  console.log('add() result = ' + result);\n});\nserverDate(function(err, date) {\n  console.log('serverDate() date UNIX timestamp: ' + date.getTime());\n});\ncustomCalc(function() {\n  console.log('Look at me, I am running on the server!');\n}, function(err) {\n  console.log('customCalc() Finished executing function on server');\n});\n\n\nRPC_Client.pipe(RPC_Server).pipe(RPC_Client);\n\n\n// Example output:\n//\n// add() result = 10\n// serverDate() date UNIX timestamp: 1383242166000\n// Look at me, I am running on the server!\n// customCalc() Finished executing function on server\n```\n\n* RPC over HTTP (10 simultaneous requests to same RPC server stream using [Conveyor](https://github.com/mscdex/conveyor)):\n\n```javascript\nvar http = require('http');\nvar Conveyor = require('conveyor'),\n    RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    c = new Conveyor(RPC_Server);\n\nRPC_Server.add(function multiply(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a * b);\n});\n\nvar TOTAL = 10, count = 0;\n\nhttp.createServer(function(req, res) {\n  if (++count === TOTAL)\n    this.close();\n  c.push(req, res);\n}).listen(8080, function() {\n  console.log('HTTP RPC server listening');\n\n  for (var i = 0; i < TOTAL; ++i) {\n    (function(n) {\n      var RPC_Client = new RPC(),\n          multiply = RPC_Client.generate('multiply'),\n          req = http.request({\n            host: '127.0.0.1',\n            port: 8080,\n            method: 'POST'\n          }, function(res) {\n            res.pipe(RPC_Client, { end: false });\n          });\n      RPC_Client.pipe(req);\n      multiply(2, n, function(err, result) {\n        console.log('Result = ' + result);\n        req.end();\n      });\n    })(i);\n  }\n});\n\n// Output:\n//\n// HTTP RPC server listening\n// Result = 0\n// Result = 2\n// Result = 4\n// Result = 6\n// Result = 8\n// Result = 10\n// Result = 12\n// Result = 14\n// Result = 16\n// Result = 18\n```\n\n* Simple Pubsub (no intermediate medium/stream):\n\n```javascript\nvar Pubsub = require('bellhop').Pubsub;\n\nvar Pubsub1 = new Pubsub(),\n    Pubsub2 = new Pubsub();\n\nPubsub1.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n});\n\nPubsub2.events.emit('today', new Date());\n\nPubsub1.pipe(Pubsub2).pipe(Pubsub1);\n\n// Example output:\n//\n// Today is: Thu Oct 31 2013 14:02:00 GMT-0400 (Eastern Daylight Time)\n```\n\n* Simple Pubsub over TCP:\n\n```javascript\nvar net = require('net');\n\nvar Pubsub = require('bellhop').Pubsub;\n\nvar PubsubRecvr = new Pubsub(),\n    PubsubSender = new Pubsub();\n\nnet.createServer(function(sock) {\n  this.close();\n  PubsubSender.pipe(sock);\n  PubsubSender.events.emit('today', new Date());\n}).listen(9000, '127.0.0.1');\n\nvar sock = new net.Socket();\nsock.pipe(PubsubRecvr);\nPubsubRecvr.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n  sock.end();\n});\nsock.connect(9000, '127.0.0.1');\n\n// Example output:\n//\n// Today is: Thu Nov 14 2013 07:52:01 GMT-0500 (Eastern Standard Time)\n```\n\n* RPC AND Pubsub over the same TCP socket:\n\n```javascript\nvar net = require('net');\n\nvar Pubsub = require('bellhop').Pubsub,\n    RPC = require('bellhop').RPC;\n\nvar rpcServer = new RPC(),\n    rpcClient = new RPC(),\n    pub = new Pubsub(),\n    sub = new Pubsub();\n\nrpcServer.add(function foo() {\n  console.log('Got RPC');\n});\n\nsub.events.on('bar', function() {\n  console.log('Got event');\n});\n\nnet.createServer(function(sock) {\n  this.close();\n  sock.pipe(rpcServer);\n  sock.pipe(sub);\n}).listen(9000, '127.0.0.1');\n\nvar sock = new net.Socket();\nrpcClient.pipe(sock);\npub.pipe(sock);\n\nsock.connect(9000, '127.0.0.1', function() {\n  rpcClient.generate('foo')();\n  pub.events.emit('bar');\n  sock.end();\n});\n\n// Output:\n//\n// Got RPC\n// Got event\n```\n\n\nBenchmarks\n==========\n\nBenchmarks can be found in `bench/`.\n\nPubsub benchmark (as of 11/14/2013) for Core i7-3770k, Windows 7 x64, node v0.10.22:\n\n```\n50000 events (no args): 327ms\n50000 events (3 short strings): 389ms\n50000 events (3 longer strings): 433ms\n50000 events (3 regexps): 654ms\n50000 events (3 functions): 874ms\n50000 events (5 numeric values): 470ms\n```\n\n\nAPI\n===\n\nAll types are _Duplex_ streams.\n\nRPC methods\n-----------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new RPC instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **ignoreInvalidCall** - _boolean_ - Do not send error responses to incoming function call requests for invalid methods (Default: false).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n* **generate**(< _string_ >remoteFuncName) - _function_ - Returns a function that can be used when calling a particular remote function. This makes things easier than using send() manually. The return value of the returned function is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **send**([< _mixed_ >arg1, ..., < _mixed_ >argn, ]< _string_ >remoteFuncName[, < _function_ >callback]) - _(boolean)_ - Calls the function identified by `remoteFuncName` (with optional arguments). The return value is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **add**(< _function_ >method[, < _string_ >methodName]) - _(void)_ - Adds a function that can be called by others. `methodName` is optional if `method` is a named function, however you can always override the name with `methodName`. The last argument passed to the function is the callback to call in case the other side requested a response. The return value of the callback is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **remove**([< _function_ >method][, < _string_ >methodName]) - _(void)_ - Removes a function previously added via add(). The removal process first checks `methodName`, then `method` for a name, and if those two are not set then *all* instances of that function are removed.\n\n\nPubsub properties\n-----------------\n\n* **events** - _EventEmitter_ - This is the event emitter object used to emit events to others and to receive events from others.\n\nPubsub (special) events\n-----------------------\n\n* __*__(< _mixed_ >event[, < _mixed_ >arg1, ..., < _mixed_ >argn]) - Emitted for every event for use as a \"catch-all.\"\n\nPubsub methods\n--------------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new Pubsub instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n\nNotes\n=====\n\n* Serialization of types unsupported by JSON is an option and is enabled by default.\n\n* Properties of \"non-plain objects\" (e.g. Dates, Functions, Errors, RegExps) are not checked for needed serialization.\n\n* Circular references are not detected.\n\n* RPC-specific:\n\n   * Callback functions follow the error-first argument pattern. Any arguments after the error argument are values returned by the other side.\n\n   * All functions returned by `generate()` will assume that a function passed as the last argument will be a callback to be executed when the server responds. If you need to pass a function to the other side, make sure a non-function value separates it and the optional callback **OR** you can use `send()` directly instead. Examples:\n\n      ```javascript\n      // ....\n      var map = RPC_Client.generate('map');\n\n      // no callback/response (THIS IS WRONG, the mapper function will not be sent to the other side and will be used as a callback instead)\n      map([0, 1, 2, 3, 4], function(n) { return n * 2; });\n\n      // no callback/response\n      map(function(n) { return n * 2; }, [0, 1, 2, 3, 4]);\n\n      // callback/response requested\n      map(function(n) { return n * 2; }, [0, 1, 2, 3, 4], function(result) { console.log('Result: ' + result); });\n\n      // OR always use `send()` directly if you want/need the mapper function to always be the second argument:\n\n      // no callback/response\n      RPC_Client.send([0, 1, 2, 3, 4], function(n) { return n * 2; }, 'map');\n\n      // callback/response requested\n      RPC_Client.send([0, 1, 2, 3, 4], function(n) { return n * 2; }, 'map', function(result) {\n        console.log('Result: ' + result);\n      });\n      ```","readmeFilename":"README.md","bugs":{"url":"https://github.com/mscdex/bellhop/issues"},"homepage":"https://github.com/mscdex/bellhop","_id":"bellhop@0.4.1","dist":{"shasum":"6d5aa0bf7b0ad9a71deb1fd6738efe71f1e9dce9","tarball":"https://registry.npmjs.org/bellhop/-/bellhop-0.4.1.tgz","integrity":"sha512-OO5v5PXmTIi7esdp9E+mzs4wSbtwpmriQMq9fyApICtDIxzhsQTEEq2c/XhJmolncLqk92ZkrtBNBDBmYVeRug==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDKdiwMpA6LguExzyEsL6bKygXsDRFYg6BEWnQmBx6poAIhAPAAmFrB4OwFLk8Szqsb/1yY205og6mkuQL4Ng5ePP7C"}]},"_from":"https://github.com/mscdex/bellhop/tarball/v0.4.1","_resolved":"https://github.com/mscdex/bellhop/tarball/v0.4.1","_npmVersion":"1.3.14","_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}]}},"readme":"\nDescription\n===========\n\nA node.js module that exposes streams for doing Pubsub and RPC.\n\nSerialization of types unsupported by JSON is also an option and is enabled by default.\nIt should also be noted that properties of \"non-plain objects\" (e.g. Dates, Functions, Errors, RegExps) are not checked for needed serialization.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n============\n\n    npm install bellhop\n\n\nExamples\n========\n\n* Simple RPC (no intermediate medium/stream):\n\n```javascript\nvar RPC = require('bellhop').RPC;\n\nvar RPC_Server = new RPC(),\n    RPC_Client = new RPC();\n\nRPC_Server.add(function add(a, b) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(a + b);\n});\nRPC_Server.add(function serverDate() {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(new Date());\n});\nRPC_Server.add(function customCalc(fn) {\n  var cb = arguments[arguments.length - 1];\n  cb && cb(fn());\n});\n\n\nvar add = RPC_Client.makeRemoteFn('add'),\n    serverDate = RPC_Client.makeRemoteFn('serverDate'),\n    customCalc = RPC_Client.makeRemoteFn('customCalc');\n\nadd(5, 5, function(result) {\n  console.log('add() result = ' + result);\n});\nserverDate(function(date) {\n  console.log('serverDate() date UNIX timestamp: ' + date.getTime());\n});\ncustomCalc(function() {\n  console.log('Look at me, I am running on the server!');\n}, function() {\n  console.log('customCalc() Finished executing function on server');\n});\n\n\nRPC_Client.pipe(RPC_Server).pipe(RPC_Client);\n\n\n// Example output:\n//\n// add() result = 10\n// serverDate() date UNIX timestamp: 1383242166000\n// Look at me, I am running on the server!\n// customCalc() Finished executing function on server\n```\n\n* Simple Pubsub (no intermediate medium/stream):\n\n```javascript\nvar Pubsub = require('bellhop').Pubsub;\n\nvar Pubsub1 = new Pubsub(),\n    Pubsub2 = new Pubsub();\n\nPubsub1.events.on('today', function(date) {\n  console.log('Today is: ' + date);\n});\n\nPubsub2.events.emit('today', new Date());\n\nPubsub1.pipe(Pubsub2).pipe(Pubsub1);\n\n\n// Example output:\n//\n// Today is: Thu Oct 31 2013 14:02:00 GMT-0400 (Eastern Daylight Time)\n```\n\n\nAPI\n===\n\nAll types are _Duplex_ streams.\n\nRPC methods\n-----------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new RPC instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n\n* **makeRemoteFn**(< _string_ >remoteFuncName) - _function_ - Returns a function that can be used when calling a particular remote function. This makes things easier than using send() manually. The return value of the returned function is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **send**([< _mixed_ >arg1, ..., < _mixed_ >argn, ]< _string_ >remoteFuncName[, < _function_ >callback]) - _(boolean)_ - Calls the function identified by `remoteFuncName` (with optional arguments). The return value is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **add**(< _function_ >method[, < _string_ >methodName]) - _(void)_ - Adds a function that can be called by others. `methodName` is optional if `method` is a named function, however you can always override the name with `methodName`. The last argument passed to the function is the callback to call in case the other side requested a response. The return value of the callback is similar to that of Writable.write() and indicates if the high water mark has been reached.\n\n* **remove**([< _function_ >method][, < _string_ >methodName]) - _(void)_ - Removes a function previously added via add(). The removal process first checks `methodName`, then `method` for a name, and if those two are not set then *all* instances of that function are removed.\n\n\nPubsub properties\n-----------------\n\n* **events** - _EventEmitter_ - This is the event emitter object used to emit events to others and to receive events from others.\n\nPubsub methods\n--------------\n\n* **(constructor)**([< _object_ >options]) - Creates and returns a new Pubsub instance with the following valid `options`:\n\n    * **serialize** - _boolean_ - Manually serialize objects that JSON does not support (well)? (Default: true).\n\n    * **highWaterMark** - _integer_ - High water mark to use for this stream (Default: Duplex stream default).\n\n    * Additionally `options` is passed to the underlying Xfer instance, allowing for configuration of Xfer too if needed (not common).\n","maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}],"time":{"modified":"2022-06-13T04:30:32.017Z","created":"2013-10-31T18:37:08.937Z","0.0.1":"2013-10-31T18:37:11.387Z","0.0.2":"2013-11-01T16:18:39.027Z","0.0.3":"2013-11-01T18:28:16.311Z","0.0.4":"2013-11-02T01:10:50.157Z","0.0.5":"2013-11-03T01:53:05.993Z","0.1.0":"2013-11-04T12:54:33.861Z","0.2.0":"2013-11-07T02:41:16.513Z","0.3.0":"2013-11-14T05:30:00.383Z","0.3.1":"2013-11-14T21:17:11.981Z","0.4.0":"2013-11-14T22:30:43.264Z","0.4.1":"2013-11-15T01:38:14.529Z"},"author":{"name":"Brian White","email":"mscdex@mscdex.net"},"repository":{"type":"git","url":"http://github.com/mscdex/bellhop.git"}}