Socket
Socket
Sign inDemoInstall

jayson

Package Overview
Dependencies
19
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.6.1 to 3.6.2

1

index.d.ts

@@ -229,2 +229,3 @@ import net = require('net');

generator?: IDGenerator;
notificationIdNull?: boolean;
}

@@ -231,0 +232,0 @@

5

lib/client/browser/index.js

@@ -15,2 +15,3 @@ 'use strict';

* @param {Function} [options.generator] Function to use for generating request IDs
* @param {Boolean} [options.notificationIdNull=false] When true, version 2 requests will set id to null instead of omitting it
* @return {ClientBrowser}

@@ -32,2 +33,3 @@ */

version: typeof options.version !== 'undefined' ? options.version : 2,
notificationIdNull: typeof options.notificationIdNull === 'boolean' ? options.notificationIdNull : false,
};

@@ -78,3 +80,4 @@

generator: this.options.generator,
version: this.options.version
version: this.options.version,
notificationIdNull: this.options.notificationIdNull,
});

@@ -81,0 +84,0 @@ } catch(err) {

@@ -16,2 +16,3 @@ 'use strict';

* @param {Number} [options.version=2] JSON-RPC version to use (1|2)
* @param {Boolean} [options.notificationIdNull=false] When true, version 2 requests will set id to null instead of omitting it
* @param {Function} [options.generator] Function to use for generating request IDs

@@ -34,3 +35,4 @@ * @return {Client}

generator: utils.generateId,
version: 2
version: 2,
notificationIdNull: false,
};

@@ -122,3 +124,3 @@

version: this.options.version,
notificationIdNull: this.options.notificationIdNull
notificationIdNull: this.options.notificationIdNull,
});

@@ -125,0 +127,0 @@ } catch(err) {

@@ -12,3 +12,3 @@ 'use strict';

* @param {Number} [options.version=2] JSON-RPC version to use (1 or 2)
* @param {Number} [options.notificationIdNull=false] When version is 2 and this option is true, the id of a notification request will be set to null instead of being omitted
* @param {Boolean} [options.notificationIdNull=false] When true, version 2 requests will set id to null instead of omitting it
* @param {Function} [options.generator] Passed the request, and the options object and is expected to return a request ID

@@ -15,0 +15,0 @@ * @throws {TypeError} If any of the parameters are invalid

{
"name": "jayson",
"version": "3.6.1",
"version": "3.6.2",
"description": "JSON-RPC 1.0/2.0 compliant server and client",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -230,2 +230,3 @@ import net = require('net');

generator?: IDGenerator;
notificationIdNull?: boolean;
}

@@ -232,0 +233,0 @@

@@ -82,8 +82,6 @@ # Jayson

```javascript
'use strict';
const jayson = require('jayson');
const jayson = require('./../..');
// create a server
const server = jayson.server({
const server = new jayson.server({
add: function(args, callback) {

@@ -100,8 +98,6 @@ callback(null, args[0] + args[1]);

```javascript
'use strict';
const jayson = require('jayson');
const jayson = require('./../..');
// create a client
const client = jayson.client.http({
const client = new jayson.client.http({
port: 3000

@@ -230,4 +226,4 @@ });

```javascript
var jayson = require('jayson');
var client = jayson.client.http('http://localhost:3000');
const jayson = require('jayson');
const client = new jayson.client.http('http://localhost:3000');
// client.options is now the result of url.parse

@@ -317,3 +313,3 @@ ```

const client = jaysonBrowserClient(callServer, {
const client = new jaysonBrowserClient(callServer, {
// other options go here

@@ -335,7 +331,5 @@ });

```javascript
'use strict';
const jayson = require('jayson');
const client = jayson.client.http({
const client = new jayson.client.http({
port: 3000

@@ -354,7 +348,5 @@ });

```javascript
'use strict';
const jayson = require('jayson');
const jayson = require('./../..');
const server = jayson.server({
const server = new jayson.server({
ping: function(args, callback) {

@@ -385,7 +377,5 @@ // do something, do nothing

```javascript
'use strict';
const jayson = require('jayson');
const server = jayson.server({
const server = new jayson.server({
add: function(args, callback) {

@@ -396,3 +386,3 @@ callback(null, args[0] + args[1]);

const client = jayson.client(server);
const client = new jayson.client(server);

@@ -514,4 +504,2 @@ const batch = [

```javascript
'use strict';
const jayson = require('jayson');

@@ -522,3 +510,3 @@ const jsonParser = require('body-parser').json;

const server = jayson.server({
const server = new jayson.server({
add: function(args, callback) {

@@ -543,7 +531,5 @@ callback(null, args[0] + args[1]);

```javascript
'use strict';
const jayson = require('jayson');
const server = jayson.server();
const server = new jayson.server();

@@ -575,9 +561,7 @@ // "http" will be an instance of require('http').Server

```javascript
'use strict';
const jayson = require('jayson');
// create a server where "add" will relay a localhost-only server
const server = jayson.server({
add: jayson.client.http({
const server = new jayson.server({
add: new jayson.client.http({
port: 3001

@@ -594,7 +578,5 @@ })

```javascript
'use strict';
const jayson = require('jayson');
const server = jayson.server({
const server = new jayson.server({
add: function(args, callback) {

@@ -618,4 +600,2 @@ callback(null, args[0] + args[1]);

```javascript
'use strict';
const jayson = require('jayson');

@@ -629,3 +609,3 @@

const server = jayson.server(methods, {
const server = new jayson.server(methods, {
router: function(method, params) {

@@ -650,8 +630,6 @@ // regular by-name routing first

```javascript
'use strict';
const jayson = require('jayson');
// create a client
const client = jayson.client.http({
const client = new jayson.client.http({
port: 3000

@@ -670,4 +648,2 @@ });

```javascript
'use strict';
const _ = require('lodash');

@@ -691,7 +667,7 @@ const jayson = require('jayson');

const map = _.reduce(methods, collapse('', '.'), {});
const server = jayson.server(map);
const server = new jayson.server(map);
function collapse(stem, sep) {
return function(map, value, key) {
var prop = stem ? stem + sep + key : key;
const prop = stem ? stem + sep + key : key;
if(_.isFunction(value)) map[prop] = value;

@@ -725,4 +701,2 @@ else if(_.isObject(value)) map = _.reduce(value, collapse(prop, sep), map);

```javascript
'use strict';
const jayson = require('jayson');

@@ -763,3 +737,3 @@ const _ = require('lodash');

const server = jayson.server(methods, {
const server = new jayson.server(methods, {
// these options are given as options to jayson.Method when adding the method "sum".

@@ -784,7 +758,5 @@ // this is because it is not wrapped in jayson.Method like the others.

```javascript
'use strict';
const jayson = require('jayson');
const client = jayson.client.http({
const client = new jayson.client.http({
port: 3000

@@ -839,7 +811,7 @@ });

```javascript
var jayson = require('jayson');
const jayson = require('jayson');
var server = jayson.server({
const server = new jayson.server({
i_cant_find_anything: function(args, callback) {
var error = {code: 404, message: 'Cannot find ' + args.id};
const error = {code: 404, message: 'Cannot find ' + args.id};
callback(error); // will return the error object as given

@@ -860,7 +832,7 @@ },

```javascript
var jayson = require('jayson');
const jayson = require('jayson');
var server = jayson.server({
const server = new jayson.server({
invalid_params: function(args, callback) {
var error = this.error(-32602); // returns an error with the default properties set
const error = this.error(-32602); // returns an error with the default properties set
callback(error);

@@ -874,5 +846,5 @@ }

```javascript
var jayson = require('jayson');
const jayson = require('jayson');
var server = jayson.server({
const server = new jayson.server({
error_giver_of_doom: function(callback) {

@@ -893,4 +865,2 @@ callback(true) // invalid error format, which causes an Internal Error to be returned instead

```javascript
'use strict';
const jayson = require('jayson');

@@ -902,3 +872,3 @@ const cors = require('cors');

const server = jayson.server({
const server = new jayson.server({
myNameIs: function(args, callback) {

@@ -927,4 +897,2 @@ callback(null, 'Your name is: ' + args.name);

```javascript
'use strict';
const _ = require('lodash');

@@ -936,3 +904,3 @@ const jayson = require('jayson');

const server = jayson.server({
const server = new jayson.server({

@@ -972,8 +940,6 @@ getHeaders: function(args, context, callback) {

```javascript
'use strict';
const jayson = require('jayson');
const jayson = require('./../..');
// create a client
const client = jayson.client.http({
const client = new jayson.client.http({
port: 3001

@@ -1035,4 +1001,2 @@ });

```javascript
'use strict';
const jayson = require('jayson');

@@ -1048,3 +1012,3 @@ const shared = require('./shared');

// create a server
const server = jayson.server({
const server = new jayson.server({
increment: function(args, callback) {

@@ -1062,8 +1026,6 @@ args.counter.increment();

```javascript
'use strict';
const jayson = require('jayson');
const shared = require('./shared');
const client = jayson.client.http({
const client = new jayson.client.http({
port: 3000,

@@ -1102,7 +1064,5 @@ reviver: shared.reviver,

```javascript
'use strict';
const jayson = require('jayson');
const client = jayson.client.http({
const client = new jayson.client.http({
port: 3000

@@ -1120,7 +1080,5 @@ });

```javascript
'use strict';
const jayson = require('jayson');
const jayson = require('./../..');
const server = jayson.server({
const server = new jayson.server({
add: function(params, callback) {

@@ -1157,22 +1115,16 @@ callback(null, params.a + params.b);

```javascript
'use strict';
const jayson = require('jayson/promise');
const _ = require('lodash');
const server = jayson.server({
const server = new jayson.server({
add: function(args) {
return new Promise(function(resolve, reject) {
const sum = _.reduce(args, function(sum, value) { return sum + value; }, 0);
resolve(sum);
});
add: async function(args) {
const sum = _.reduce(args, function(sum, value) { return sum + value; }, 0);
return sum;
},
// example on how to reject
rejection: function(args) {
return new Promise(function(resolve, reject) {
// server.error just returns {code: 501, message: 'not implemented'}
reject(server.error(501, 'not implemented'));
});
rejection: async function(args) {
// server.error just returns {code: 501, message: 'not implemented'}
throw server.error(501, 'not implemented');
}

@@ -1188,7 +1140,5 @@

```javascript
'use strict';
const jayson = require('jayson/promise');
const client = jayson.client.http({
const client = new jayson.client.http({
port: 3000

@@ -1224,7 +1174,5 @@ });

```javascript
'use strict';
const jayson = require('jayson/promise');
const jayson = require('../../promise');
const client = jayson.client.http({
const client = new jayson.client.http({
port: 3000

@@ -1269,3 +1217,3 @@ });

const client = jaysonPromiseBrowserClient(callServer, {
const client = new jaysonPromiseBrowserClient(callServer, {
// other options go here

@@ -1307,6 +1255,4 @@ });

```javascript
'use strict';
const _ = require('lodash');
const jayson = require('./../..');
const jayson = require('jayson');
const jsonParser = require('body-parser').json;

@@ -1317,3 +1263,3 @@ const express = require('express');

// create a plain jayson server
const server = jayson.server({
const server = new jayson.server({
add: function(numbers, callback) {

@@ -1354,5 +1300,3 @@ callback(null, _.reduce(numbers, (sum, val) => sum + val, 0));

```javascript
'use strict';
const jayson = require('./../..');
const jayson = require('jayson');
const request = require('superagent');

@@ -1359,0 +1303,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc