{"_id":"jsonrpc-dispatch","_rev":"49-4f43b1de70af5d35152da0a6ad384738","name":"jsonrpc-dispatch","dist-tags":{"latest":"2.3.0"},"versions":{"1.0.0":{"name":"jsonrpc-dispatch","version":"1.0.0","keywords":["JSONRPC","Cerner"],"author":{"name":"Cerner Corporation"},"license":"Apache-2.0","_id":"jsonrpc-dispatch@1.0.0","maintainers":[{"name":"cerner","email":"kevin.shekleton+cerner-npm@gmail.com"}],"homepage":"https://github.com/cerner/jsonrpc-dispatch#readme","bugs":{"url":"https://github.com/cerner/jsonrpc-dispatch/issues"},"dist":{"shasum":"2a901b5beccbb8ad61fcb44e9b3cd95df5b23e80","tarball":"https://registry.npmjs.org/jsonrpc-dispatch/-/jsonrpc-dispatch-1.0.0.tgz","integrity":"sha512-fp1FFFN1IJLpKPqDy9ATsnAMYmxnNmjSoL0cQH6xsV8yhogBWzZF4k9t+lslpX7zvH16SN/Ob0gyyfQis7IGgw==","signatures":[{"sig":"MEYCIQCwT3NjOj5DCQBUE0191zP1y/Qnzq7Z5B8HZqmvnoJ4tAIhAM2V+YY5kyvcgUynt7OvDsxnA8r3+agIkql69rWY9vwv","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/src/index.js","_from":".","_shasum":"2a901b5beccbb8ad61fcb44e9b3cd95df5b23e80","engines":{"node":">= 6.0"},"gitHead":"bbe83bd552ea7fbe76114d3e747deb137a7022d4","scripts":{"test":"mocha --compilers js:babel-core/register test","build":"npm run clean && npm run test && npm run lint-js && npm run build-es5","clean":"rm -rf dist lib","lint-js":"eslint src/* test/*","build-es5":"babel src --out-dir lib/src"},"_npmUser":{"name":"cerner","email":"kevin.shekleton+cerner-npm@gmail.com"},"repository":{"url":"git+https://github.com/cerner/jsonrpc-dispatch.git","type":"git"},"_npmVersion":"3.6.0","description":"An unopinionated JSONRPC dispatcher for JavaScript","directories":{},"_nodeVersion":"5.6.0","dependencies":{"node-uuid":"1.4.7"},"devDependencies":{"chai":"3.5.0","mocha":"2.4.5","eslint":"^2.11.1","babel-cli":"^6.11.4","babel-core":"^6.13.1","babel-preset-es2015":"^6.6.0","eslint-plugin-import":"^1.8.1","eslint-config-airbnb-base":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/jsonrpc-dispatch-1.0.0.tgz_1470405271528_0.41668919660151005","host":"packages-12-west.internal.npmjs.com"}},"2.0.0":{"name":"jsonrpc-dispatch","version":"2.0.0","keywords":["JSONRPC","Cerner"],"author":{"name":"Cerner Corporation"},"license":"Apache-2.0","_id":"jsonrpc-dispatch@2.0.0","maintainers":[{"name":"cerner","email":"kevin.shekleton+cerner-npm@gmail.com"},{"name":"gneatgeek","email":"gneatgeek@gmail.com"},{"name":"mhemesath","email":"mike.hemesath@gmail.com"}],"homepage":"https://github.com/cerner/jsonrpc-dispatch#readme","bugs":{"url":"https://github.com/cerner/jsonrpc-dispatch/issues"},"dist":{"shasum":"496b06ee50dc2193ad63a55ebce479e5df62bd99","tarball":"https://registry.npmjs.org/jsonrpc-dispatch/-/jsonrpc-dispatch-2.0.0.tgz","integrity":"sha512-UVhKpbh9IsuHJHphsclPoyf/NKoOVQApIpVwZBMoB14XEfsIpHLyrFgqoBiWBA8uetHVqwB7SQMklBE64nk2sg==","signatures":[{"sig":"MEQCIGqMeuDfn9ZtMHuHrjxKBwIEx7thwvLa9IdCSWODq88jAiBHGlJuDGiQcNp+hgVGjTBkd5kz9eanp+aVwJnqqdbP4A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/src/index.js","_from":".","files":["lib"],"_shasum":"496b06ee50dc2193ad63a55ebce479e5df62bd99","engines":{"node":">= 6.0"},"gitHead":"625045a5946fd2295d8e2b18c9bcf60f0f809765","scripts":{"test":"npm run lint-js && mocha --compilers js:babel-core/register test","build":"npm run clean && npm run test && npm run lint-js && npm run build-es5","clean":"rm -rf dist lib","lint-js":"eslint src/* test/*","build-es5":"babel src --out-dir lib/src","prepublish":"npm run build-es5"},"_npmUser":{"name":"mhemesath","email":"mike.hemesath@gmail.com"},"repository":{"url":"git+https://github.com/cerner/jsonrpc-dispatch.git","type":"git"},"_npmVersion":"3.8.6","description":"An unopinionated JSONRPC dispatcher for JavaScript","directories":{},"_nodeVersion":"6.0.0","dependencies":{"node-uuid":"1.4.7"},"devDependencies":{"chai":"3.5.0","mocha":"2.4.5","eslint":"^2.11.1","babel-cli":"^6.11.4","babel-core":"^6.13.1","babel-preset-es2015":"^6.6.0","eslint-plugin-import":"^1.8.1","eslint-config-airbnb-base":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/jsonrpc-dispatch-2.0.0.tgz_1471534858615_0.9531667369883507","host":"packages-12-west.internal.npmjs.com"}},"2.1.0":{"name":"jsonrpc-dispatch","version":"2.1.0","keywords":["JSONRPC","Cerner"],"author":{"name":"Cerner Corporation"},"license":"Apache-2.0","_id":"jsonrpc-dispatch@2.1.0","maintainers":[{"name":"cerner","email":"kevin.shekleton+cerner-npm@gmail.com"},{"name":"gneatgeek","email":"gneatgeek@gmail.com"},{"name":"mhemesath","email":"mike.hemesath@gmail.com"}],"homepage":"https://github.com/cerner/jsonrpc-dispatch#readme","bugs":{"url":"https://github.com/cerner/jsonrpc-dispatch/issues"},"dist":{"shasum":"9a67feed8e3e720e7a362945bf7794202b9f2862","tarball":"https://registry.npmjs.org/jsonrpc-dispatch/-/jsonrpc-dispatch-2.1.0.tgz","integrity":"sha512-MgCtSPVavrCrG3/jkAVWnrd8z4nk+z681qI+extutP2tpQJtTrLfKG9Fk8QaQPNn5764/kxXjMHXzljrO7WgkA==","signatures":[{"sig":"MEUCIQClEOZptnGBjUvGD7hpLrtDKVyhWnVZwi6qKKrquIY4DwIgRtBNCDoa9UQh36DtljPeLKNMTtDit5gYOAjcFaeSvso=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/src/index.js","_from":".","files":["lib"],"_shasum":"9a67feed8e3e720e7a362945bf7794202b9f2862","engines":{"node":">= 6.0"},"gitHead":"8270474a115ce5c134151630885bc8b398b43f22","scripts":{"test":"npm run lint-js && mocha --compilers js:babel-core/register test","build":"npm run clean && npm run test && npm run lint-js && npm run build-es5","clean":"rm -rf dist lib","lint-js":"eslint src/* test/*","build-es5":"babel src --out-dir lib/src","prepublish":"npm run build"},"_npmUser":{"name":"cerner","email":"kevin.shekleton+cerner-npm@gmail.com"},"repository":{"url":"git+https://github.com/cerner/jsonrpc-dispatch.git","type":"git"},"_npmVersion":"3.10.3","description":"An unopinionated JSONRPC dispatcher for JavaScript","directories":{},"_nodeVersion":"6.6.0","dependencies":{"uuid":"^3.0.0"},"devDependencies":{"chai":"3.5.0","mocha":"2.4.5","eslint":"^2.11.1","babel-cli":"^6.11.4","babel-core":"^6.13.1","babel-preset-es2015":"^6.6.0","eslint-plugin-import":"^1.8.1","eslint-config-airbnb-base":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/jsonrpc-dispatch-2.1.0.tgz_1481123250383_0.723916083574295","host":"packages-18-east.internal.npmjs.com"}},"2.3.0":{"name":"jsonrpc-dispatch","version":"2.3.0","keywords":["JSONRPC","Cerner"],"author":{"name":"Cerner Corporation"},"license":"Apache-2.0","_id":"jsonrpc-dispatch@2.3.0","maintainers":[{"name":"mike.antonelli","email":"mike.antonelli@me.com"},{"name":"kafkahw","email":"houweikafka@gmail.com"},{"name":"ryanthemanuel","email":"rfmanuel@gmail.com"},{"name":"mjhenkes","email":"mjhenkes@gmail.com"},{"name":"bjankord","email":"bjankord@gmail.com"},{"name":"sambao21","email":"sambao21@gmail.com"},{"name":"kpshek","email":"kevin.shekleton@gmail.com"},{"name":"cerner-oss","email":"kevin.shekleton+cerner-npm@gmail.com"}],"homepage":"https://github.com/cerner/jsonrpc-dispatch#readme","bugs":{"url":"https://github.com/cerner/jsonrpc-dispatch/issues"},"dist":{"shasum":"4e1ff9f586a7b892c03e36096a8523f9e49804ed","tarball":"https://registry.npmjs.org/jsonrpc-dispatch/-/jsonrpc-dispatch-2.3.0.tgz","integrity":"sha512-yH+Z4RIVI/3qBPNHLCvUOOTGfFt2a7e4iSZ3QEBfg4eK/NLIz5yDkIuR4dmqxEyCpdOVHV+fjOTFYe03g2cX2g==","signatures":[{"sig":"MEYCIQDfCf6EgfCrYu7+uYCp79EJMjNAvmYh01Gy5RLf7FZDbgIhAJCzXVqWMP8LNjjpGP7eItPWq09UiZlxbMmrTqyVrhGb","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/src/index.js","files":["lib"],"engines":{"node":">= 6.0"},"gitHead":"b5bd51b07b6573347bcc708ef8f2475082be3e0c","scripts":{"test":"npm run lint-js && mocha --compilers js:babel-core/register test","build":"npm run clean && npm run test && npm run lint-js && npm run build-es5","clean":"rm -rf dist lib","lint-js":"eslint src/* test/*","build-es5":"babel src --out-dir lib/src","prepublish":"npm run build"},"_npmUser":{"name":"kafkahw","email":"houweikafka@gmail.com"},"repository":{"url":"git+https://github.com/cerner/jsonrpc-dispatch.git","type":"git"},"_npmVersion":"5.3.0","description":"An unopinionated JSONRPC dispatcher for JavaScript","directories":{},"_nodeVersion":"8.5.0","dependencies":{"uuid":"^3.0.0","babel-runtime":"^6.26.0"},"devDependencies":{"chai":"3.5.0","mocha":"2.4.5","eslint":"^2.11.1","babel-cli":"^6.11.4","babel-core":"^6.13.1","babel-preset-env":"^1.6.0","eslint-plugin-import":"^1.8.1","eslint-config-airbnb-base":"^3.0.1","babel-plugin-transform-runtime":"^6.23.0","babel-plugin-transform-object-assign":"^6.22.0"},"_npmOperationalInternal":{"tmp":"tmp/jsonrpc-dispatch-2.3.0.tgz_1507843419978_0.31606977549381554","host":"s3://npm-registry-packages"}}},"time":{"created":"2016-08-05T13:54:33.448Z","modified":"2024-11-26T13:15:27.881Z","1.0.0":"2016-08-05T13:54:33.448Z","2.0.0":"2016-08-18T15:41:00.370Z","2.1.0":"2016-12-07T15:07:31.013Z","2.3.0":"2017-10-12T21:23:40.978Z"},"bugs":{"url":"https://github.com/cerner/jsonrpc-dispatch/issues"},"author":{"name":"Cerner Corporation"},"license":"Apache-2.0","homepage":"https://github.com/cerner/jsonrpc-dispatch#readme","keywords":["JSONRPC","Cerner"],"repository":{"url":"git+https://github.com/cerner/jsonrpc-dispatch.git","type":"git"},"description":"An unopinionated JSONRPC dispatcher for JavaScript","maintainers":[{"email":"kevin.shekleton+cerner-npm@gmail.com","name":"cerner-oss"},{"email":"kevin.shekleton@gmail.com","name":"kpshek"},{"email":"sambao21@gmail.com","name":"sambao21"},{"email":"kol.kheang@gmail.com","name":"kol"},{"email":"jessica.randle@oracle.com","name":"jessierandle"},{"email":"elliott.hoffman@hey.com","name":"xenoworf"}],"readme":"# JSONRPC Dispatch\n\n[![NPM version](http://img.shields.io/npm/v/jsonrpc-dispatch.svg)](https://www.npmjs.org/package/jsonrpc-dispatch)\n[![Build Status](https://travis-ci.org/cerner/jsonrpc-dispatch.svg?branch=master)](https://travis-ci.org/cerner/jsonrpc-dispatch)\n\nJSONRPC is a module for managing [JSONRPC](http://json-rpc.org) requests and\nresponses in JavaScript.\n\nThis implementation is agnostic of the transport mechanism to send and receive\nJSONRPC messages.  This means it can be easily integrated with XMLHttpRequests,\nHTTPServer, and postMessage cross domain messaging.\nA few of the features included are:\n\n* Async request/response support using promises\n* Method handling for JSONRPC requests\n* Method not found handling\n\n## Includng JSONRPC\n\nAdd `jsonrpc-dispatch` to your package.json\n\n```\nnpm install jsonrpc-dispatch --save\n```\n\nRequire the JSONRPC constructor into the module.\n\n```js\nimport JSONRPC from 'jsonrpc-dispatch'\n```\n## Using JSONRPC\n\nThe JSONRPC takes 2 arguments: a dispatcher and an object mapping of\nmethods it will take requests for.\n\n\n```js\nconst jsonrpc = new JSONRPC([dispatcher], [methods]);\n```\n\n| name       | type     | description                                                                                                                                 |\n|------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------|\n| dispatcher | function | A handler which is passed the JSONRPC message object to send.                                                                               |\n| methods    | object   | A mapping of method names to function objects which the JSONRPC instance will handle requests for. The functions **must** return a promise. |\n\n### Example\nThe below example creates a JSONRPC instance which supports a single API to add\nparameters together. The result is sent through the dispatcher to the parent\nframe using the `postMessage` API.\n\n```js\nconst methods = {\n  add(x, y) {\n    // Always return a promise\n    return Promise.resolve(x + y);\n  }\n};\n\nconst dispatcher = (message) => {\n  // Post a message to the parent frame\n  parent.postMessage(message, 'https://trustedDomain.com');\n};\n\nconst jsonrpc = new JSONRPC(dispatcher, methods);\n```\n\n### JSONRPC#request\nhttp://www.jsonrpc.org/specification#request_object\n\nSends a JSONRPC request to the provided dispatcher. The request takes 2\nparameters\n\n| name       | type            | description                                          |\n|------------|-----------------|------------------------------------------------------|\n| name       | String          | The method name to send the request for              |\n| parameters | Array or Object | (Optional) The parameters to pass to the method call |\n\nReturns an instance of a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which is resolved or rejected when the response is received.\n\n```js\njsonrpc.request('foobar', ['biz', 'baz']).then((result) => {\n  // TODO: do something with result\n});\n```\n\n\n### JSONRPC#notification\nhttp://www.jsonrpc.org/specification#notification\n\nSends a JSONRPC notification request to the provided dispatcher.\nNotifications are similar to requests but do not have any responses and thus\ndo not return a promise. Notifications take 2 parameters:\n\n\n| name       | type            | description                                          |\n|------------|-----------------|------------------------------------------------------|\n| name       | String          | The method name to send the request for              |\n| parameters | Array or Object | (Optional) The parameters to pass to the method call |\n\n```js\njsonrpc.notification('foobar', ['biz', 'baz']);\n```\n\n\n\n### JSONRPC#handle\n\nProcesses incoming JSONRPC messages to be handled as requests, responses\nor notifications. Handle takes a single argument:\n\n| name    | type   | description                                                                                                                                         |\n|---------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| message | Object | A JSONRPC [request](http://www.jsonrpc.org/specification#request_object) or [response](http://www.jsonrpc.org/specification#response_object) object |\n\n```js\njsonrpc.handle({\n  id: '1',\n  method: 'add',\n  params: [1, 2],\n  jsonrpc: '2.0'\n});\n\n```\n\n## Examples\n\n### AJAX with jQuery\n\nHere is an example usage using AJAX as a transport mechanism to call a JSONRPC\nservice which handles adding 2 numbers together.\n\n```js\n// 1. Create new JSONRPC instance which only makes requests.\n// Pass a dispatcher to post the messages to a server using jQuery.\n// Have the dispatcher pass the AJAX response to the jsonrpc#handle method.\nconst jsonrpc = new JSONRPC((message) => {\n  $.post('/jsonrpc-service', message, jsonrpc.handle.bind(jsonrpc), 'json')\n})\n\n// 2. Send a JSONRPC request then print out the result\njsonrpc.request('add', [1,2]).then((result) => {\n  console.log('1 + 2 = ', result)\n});\n```\n\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md)\n\n## LICENSE\n\nCopyright 2016 Cerner Innovation, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\n&nbsp;&nbsp;&nbsp;&nbsp;http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n","readmeFilename":"README.md"}