Comparing version 3.3.2 to 3.3.3
import * as jayson from '../../..'; | ||
type ClientBrowserCallServerFunction = (request:jayson.JSONRPCRequestLike, callback:jayson.JSONRPCCallbackType) => void; | ||
type ClientBrowserCallServerFunctionCallback = (err?:Error | null, response?:string) => void; | ||
type ClientBrowserCallServerFunction = (request:string, callback:ClientBrowserCallServerFunctionCallback) => void; | ||
declare class ClientBrowser { | ||
@@ -6,0 +8,0 @@ constructor(callServer:ClientBrowserCallServerFunction, options:jayson.ClientOptions); |
@@ -7,11 +7,11 @@ 'use strict'; | ||
/** | ||
* Constructor for a Jayson Browser Client that does not depend any node.js core libraries | ||
* @class ClientBrowser | ||
* @param {Function} callServer Method that calls the server, receives the stringified request and a regular node-style callback | ||
* @param {Object} [options] | ||
* @param {Function} [options.reviver] Reviver function for JSON | ||
* @param {Function} [options.replacer] Replacer function for JSON | ||
* @param {Number} [options.version=2] JSON-RPC version to use (1|2) | ||
* @param {Function} [options.generator] Function to use for generating request IDs | ||
* @return {ClientBrowser} | ||
* Constructor for a Jayson Browser Client that does not depend any node.js core libraries | ||
* @class ClientBrowser | ||
* @param {Function} callServer Method that calls the server, receives the stringified request and a regular node-style callback | ||
* @param {Object} [options] | ||
* @param {Function} [options.reviver] Reviver function for JSON | ||
* @param {Function} [options.replacer] Replacer function for JSON | ||
* @param {Number} [options.version=2] JSON-RPC version to use (1|2) | ||
* @param {Function} [options.generator] Function to use for generating request IDs | ||
* @return {ClientBrowser} | ||
*/ | ||
@@ -18,0 +18,0 @@ const ClientBrowser = function(callServer, options) { |
{ | ||
"name": "jayson", | ||
"version": "3.3.2", | ||
"version": "3.3.3", | ||
"description": "JSON-RPC 1.0/2.0 compliant server and client", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -58,2 +58,3 @@ # Jayson | ||
- [Batches](#promise-batches) | ||
- [Browser client](#promise-browser-client) | ||
- [FAQ](#faq) | ||
@@ -121,2 +122,6 @@ - [Recommended usage](#what-is-the-recommended-way-to-use-jayson) | ||
- *3.3.3* | ||
- Promise support for browser client | ||
- TypeScript declaration for promise browser client | ||
- TypeScript declaration for browser client | ||
- *3.3.0* | ||
@@ -268,3 +273,3 @@ - Remove URL parsing when passing a string option to the TLS and TCP client, string options are instead treated as an IPC path | ||
const jaysonBrowserClient = require('./../../lib/client/browser'); | ||
const jaysonBrowserClient = require('jayson/lib/client/browser'); | ||
const fetch = require('node-fetch'); | ||
@@ -306,3 +311,3 @@ | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
@@ -353,3 +358,3 @@ const client = jayson.client.http({ | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
@@ -481,3 +486,3 @@ const server = jayson.server({ | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
const jsonParser = require('body-parser').json; | ||
@@ -509,3 +514,3 @@ const connect = require('connect'); | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
@@ -541,3 +546,3 @@ const server = jayson.server(); | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
@@ -560,3 +565,3 @@ // create a server where "add" will relay a localhost-only server | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
@@ -584,3 +589,3 @@ const server = jayson.server({ | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
@@ -615,3 +620,3 @@ const methods = { | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
@@ -688,3 +693,3 @@ // create a client | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
const _ = require('lodash'); | ||
@@ -746,3 +751,3 @@ | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
@@ -852,3 +857,3 @@ const client = jayson.client.http({ | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
const cors = require('cors'); | ||
@@ -886,3 +891,3 @@ const connect = require('connect'); | ||
const _ = require('lodash'); | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
const jsonParser = require('body-parser').json; | ||
@@ -991,3 +996,3 @@ const express = require('express'); | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
const shared = require('./shared'); | ||
@@ -1017,3 +1022,3 @@ | ||
const jayson = require('./../..'); | ||
const jayson = require('jayson'); | ||
const shared = require('./shared'); | ||
@@ -1110,3 +1115,3 @@ | ||
const jayson = require('../../promise'); | ||
const jayson = require('jayson/promise'); | ||
const _ = require('lodash'); | ||
@@ -1141,3 +1146,3 @@ | ||
const jayson = require('../../promise'); | ||
const jayson = require('jayson/promise'); | ||
@@ -1198,2 +1203,36 @@ const client = jayson.client.http({ | ||
#### Promise Browser Client | ||
A browser client that has no dependencies on node.js core libraries is available too. It works similar to how the regular callback-style [Browser Client](#clientbrowser) works. Here is an example: | ||
```javascript | ||
'use strict'; | ||
const jaysonPromiseBrowserClient = require('jayson/promise/lib/client/browser'); | ||
const fetch = require('node-fetch'); | ||
const callServer = function(request) { | ||
const options = { | ||
method: 'POST', | ||
body: request, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
} | ||
}; | ||
return fetch('http://localhost:3000', options).then(res => res.text()); | ||
}; | ||
const client = jaysonPromiseBrowserClient(callServer, { | ||
// other options go here | ||
}); | ||
client.request('multiply', [5, 5]).then(function(result) { | ||
console.log(result); | ||
}, function(err) { | ||
console.error(err); | ||
}); | ||
``` | ||
Please refer to the [regular browser client](#clientbrowser) section of the README for more information. | ||
## FAQ | ||
@@ -1200,0 +1239,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
140858
37
2478
1345