@adt/json-rpc
Advanced tools
Comparing version 0.0.1-SNAPSHOT.22 to 0.0.1-SNAPSHOT.27
@@ -20,8 +20,3 @@ 'use strict'; | ||
return JSON.stringify(this); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
} | ||
} | ||
} } | ||
})); | ||
@@ -307,20 +302,23 @@ | ||
return Object.freeze(Object.create(JsonRpcEvent.prototype, /** @lends JsonRpcEvent.prototype */{ | ||
var instance = Object.create(JsonRpcEvent.prototype); | ||
instance.method = method; | ||
instance.params = params; | ||
method: { value: method }, | ||
params: { value: params }, | ||
serialize: { value: function value() { | ||
return JSON.stringify({ jsonrpc: this.jsonrpc, | ||
method: this.method, | ||
params: this.params }); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
} | ||
} | ||
})); | ||
return Object.freeze(instance); | ||
} | ||
JsonRpcEvent.prototype = Object.freeze(Object.create(JsonRpcElement.prototype)); | ||
JsonRpcEvent.prototype = Object.create(JsonRpcElement.prototype, /** @lends JsonRpcElement.prototype */{ | ||
method: { writable: true }, | ||
params: { writable: true }, | ||
serialize: { value: function value() { | ||
return JSON.stringify({ jsonrpc: this.jsonrpc, | ||
method: this.method, | ||
params: this.params }); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
} | ||
} | ||
}); | ||
@@ -401,36 +399,43 @@ /** | ||
return Object.freeze(Object.create(JsonRpcRequest.prototype, /** @lends JsonRpcRequest.prototype */{ | ||
//return Object.freeze(Object.create(JsonRpcRequest.prototype,)); | ||
var instance = Object.create(JsonRpcRequest.prototype); | ||
instance.id = id; | ||
instance.method = method; | ||
instance.params = params; | ||
method: { value: method }, | ||
params: { value: params }, | ||
id: { value: id }, | ||
return Object.freeze(instance); | ||
} | ||
/** | ||
* Serialize request object to string | ||
* @return {String} | ||
*/ | ||
serialize: { value: function value() { | ||
JsonRpcRequest.prototype = Object.create(JsonRpcElement.prototype, /** @lends JsonRpcRequest.prototype */{ | ||
var ret = { | ||
jsonrpc: this.jsonrpc, | ||
id: this.id, | ||
method: this.method | ||
}; | ||
method: { writable: true }, | ||
params: { writable: true }, | ||
id: { writable: true }, | ||
if (typeof this.params !== "undefined") { | ||
ret.params = this.params; | ||
} | ||
/** | ||
* Serialize request object to string | ||
* @return {String} | ||
*/ | ||
serialize: { value: function value() { | ||
return JSON.stringify(ret); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
var ret = { | ||
jsonrpc: this.jsonrpc, | ||
id: this.id, | ||
method: this.method | ||
}; | ||
if (typeof this.params !== "undefined") { | ||
ret.params = this.params; | ||
} | ||
return JSON.stringify(ret); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
} | ||
})); | ||
} | ||
} | ||
}); | ||
JsonRpcRequest.prototype = Object.freeze(Object.create(JsonRpcElement.prototype)); | ||
/** | ||
@@ -437,0 +442,0 @@ * JSON-RPC Response |
@@ -16,8 +16,3 @@ /** | ||
return JSON.stringify(this); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
} | ||
} | ||
} } | ||
})); | ||
@@ -303,20 +298,23 @@ | ||
return Object.freeze(Object.create(JsonRpcEvent.prototype, /** @lends JsonRpcEvent.prototype */{ | ||
var instance = Object.create(JsonRpcEvent.prototype); | ||
instance.method = method; | ||
instance.params = params; | ||
method: { value: method }, | ||
params: { value: params }, | ||
serialize: { value: function value() { | ||
return JSON.stringify({ jsonrpc: this.jsonrpc, | ||
method: this.method, | ||
params: this.params }); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
} | ||
} | ||
})); | ||
return Object.freeze(instance); | ||
} | ||
JsonRpcEvent.prototype = Object.freeze(Object.create(JsonRpcElement.prototype)); | ||
JsonRpcEvent.prototype = Object.create(JsonRpcElement.prototype, /** @lends JsonRpcElement.prototype */{ | ||
method: { writable: true }, | ||
params: { writable: true }, | ||
serialize: { value: function value() { | ||
return JSON.stringify({ jsonrpc: this.jsonrpc, | ||
method: this.method, | ||
params: this.params }); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
} | ||
} | ||
}); | ||
@@ -397,36 +395,43 @@ /** | ||
return Object.freeze(Object.create(JsonRpcRequest.prototype, /** @lends JsonRpcRequest.prototype */{ | ||
//return Object.freeze(Object.create(JsonRpcRequest.prototype,)); | ||
var instance = Object.create(JsonRpcRequest.prototype); | ||
instance.id = id; | ||
instance.method = method; | ||
instance.params = params; | ||
method: { value: method }, | ||
params: { value: params }, | ||
id: { value: id }, | ||
return Object.freeze(instance); | ||
} | ||
/** | ||
* Serialize request object to string | ||
* @return {String} | ||
*/ | ||
serialize: { value: function value() { | ||
JsonRpcRequest.prototype = Object.create(JsonRpcElement.prototype, /** @lends JsonRpcRequest.prototype */{ | ||
var ret = { | ||
jsonrpc: this.jsonrpc, | ||
id: this.id, | ||
method: this.method | ||
}; | ||
method: { writable: true }, | ||
params: { writable: true }, | ||
id: { writable: true }, | ||
if (typeof this.params !== "undefined") { | ||
ret.params = this.params; | ||
} | ||
/** | ||
* Serialize request object to string | ||
* @return {String} | ||
*/ | ||
serialize: { value: function value() { | ||
return JSON.stringify(ret); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
var ret = { | ||
jsonrpc: this.jsonrpc, | ||
id: this.id, | ||
method: this.method | ||
}; | ||
if (typeof this.params !== "undefined") { | ||
ret.params = this.params; | ||
} | ||
return JSON.stringify(ret); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
} | ||
})); | ||
} | ||
} | ||
}); | ||
JsonRpcRequest.prototype = Object.freeze(Object.create(JsonRpcElement.prototype)); | ||
/** | ||
@@ -433,0 +438,0 @@ * JSON-RPC Response |
@@ -28,8 +28,3 @@ (function (global, factory) { | ||
return JSON.stringify(this); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
} | ||
} | ||
} } | ||
})); | ||
@@ -315,20 +310,23 @@ | ||
return Object.freeze(Object.create(JsonRpcEvent.prototype, /** @lends JsonRpcEvent.prototype */{ | ||
var instance = Object.create(JsonRpcEvent.prototype); | ||
instance.method = method; | ||
instance.params = params; | ||
method: { value: method }, | ||
params: { value: params }, | ||
serialize: { value: function value() { | ||
return JSON.stringify({ jsonrpc: this.jsonrpc, | ||
method: this.method, | ||
params: this.params }); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
} | ||
} | ||
})); | ||
return Object.freeze(instance); | ||
} | ||
JsonRpcEvent.prototype = Object.freeze(Object.create(JsonRpcElement.prototype)); | ||
JsonRpcEvent.prototype = Object.create(JsonRpcElement.prototype, /** @lends JsonRpcElement.prototype */{ | ||
method: { writable: true }, | ||
params: { writable: true }, | ||
serialize: { value: function value() { | ||
return JSON.stringify({ jsonrpc: this.jsonrpc, | ||
method: this.method, | ||
params: this.params }); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
} | ||
} | ||
}); | ||
@@ -409,36 +407,43 @@ /** | ||
return Object.freeze(Object.create(JsonRpcRequest.prototype, /** @lends JsonRpcRequest.prototype */{ | ||
//return Object.freeze(Object.create(JsonRpcRequest.prototype,)); | ||
var instance = Object.create(JsonRpcRequest.prototype); | ||
instance.id = id; | ||
instance.method = method; | ||
instance.params = params; | ||
method: { value: method }, | ||
params: { value: params }, | ||
id: { value: id }, | ||
return Object.freeze(instance); | ||
} | ||
/** | ||
* Serialize request object to string | ||
* @return {String} | ||
*/ | ||
serialize: { value: function value() { | ||
JsonRpcRequest.prototype = Object.create(JsonRpcElement.prototype, /** @lends JsonRpcRequest.prototype */{ | ||
var ret = { | ||
jsonrpc: this.jsonrpc, | ||
id: this.id, | ||
method: this.method | ||
}; | ||
method: { writable: true }, | ||
params: { writable: true }, | ||
id: { writable: true }, | ||
if (typeof this.params !== "undefined") { | ||
ret.params = this.params; | ||
} | ||
/** | ||
* Serialize request object to string | ||
* @return {String} | ||
*/ | ||
serialize: { value: function value() { | ||
return JSON.stringify(ret); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
var ret = { | ||
jsonrpc: this.jsonrpc, | ||
id: this.id, | ||
method: this.method | ||
}; | ||
if (typeof this.params !== "undefined") { | ||
ret.params = this.params; | ||
} | ||
return JSON.stringify(ret); | ||
} }, | ||
toJSON: { | ||
value: function value() { | ||
return this.serialize(); | ||
} | ||
})); | ||
} | ||
} | ||
}); | ||
JsonRpcRequest.prototype = Object.freeze(Object.create(JsonRpcElement.prototype)); | ||
/** | ||
@@ -445,0 +450,0 @@ * JSON-RPC Response |
{ | ||
"name": "@adt/json-rpc", | ||
"version": "0.0.1-SNAPSHOT.22", | ||
"version": "0.0.1-SNAPSHOT.27", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/JsonRpc.cjs.js", |
@@ -15,5 +15,45 @@ # JsonRpc [![npm version](https://badge.fury.io/js/%40adt%2Fjson-rpc.svg)](https://badge.fury.io/js/%40adt%2Fjson-rpc) [![Build Status](https://travis-ci.org/AwesomeDevTeam/js-JsonRpc.svg?branch=master)](https://travis-ci.org/AwesomeDevTeam/js-JsonRpc) | ||
npm install @adt/json-rpc | ||
or | ||
yarn add @adt/json-rpc | ||
## Usage | ||
```javascrtipt | ||
import { JsoRpcEvent, JsonRpcRequest } from "@adt/json-rpc" | ||
const byeEvent = JsonRpcEvent({ | ||
method: "Bye", | ||
params:{ | ||
name: "Joe" | ||
} | ||
}); | ||
console.log(byeEvent.serialize()); | ||
const helloRequest = JsonRpcRequest({ | ||
method: "Hello", | ||
params: { | ||
name: "Joe"; | ||
} | ||
}); | ||
console.log(helloRequest.serialize()); | ||
const helloRequestWithExplicitId = JsonRpcRequest({ | ||
id: 1, | ||
method: "Hello", | ||
params: { | ||
name: "Joe"; | ||
} | ||
}); | ||
console.log(helloRequestWithExplicitId.serialize()); | ||
``` | ||
For more use cases please look at test specs. | ||
## Why i should use Json-RPC? | ||
TODO :) | ||
## When i can use Json-RPC? | ||
TODO :) |
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
52194
1509
59