soggie / jsonrpc-serializer Goto Github PK
View Code? Open in Web Editor NEWA simple library to serialize and deserialize JSON-RPC messages. Full support for Error and Date objects.
A simple library to serialize and deserialize JSON-RPC messages. Full support for Error and Date objects.
And in package.json, "main" is "index.js".
i just updated to version 0.2.0, but im getting an error when running. I think its because im using an older version of node: 4.6.2, but none the less i think you use need to use strict mode to fix this.
/home/developer/src/json-rpc-core/node_modules/jsonrpc-serializer/lib/serializer.js:415
let obj = null
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
It's the same error all over every JavaScript's JSON-RPC implementation.
Your implementation confuse requests and notifications if id
is set to some falsy value like 0
or false
.
You are adding additional data parameters to the error object with this call
JsonRpcError = function JsonRpcError(msg) {
this.name = 'JsonRpcError';
this.code = -32603;
this.message = msg;
this.data = Array.prototype.slice.call(arguments).splice();
};
The problem is that this.data always ends up with an empty array since calling splice with no arguments always returns []. I'm not sure what you intended to do with the data parameter, but it would be nice if this could be fixed so that we can add additional data to the error such as the stack dump, etc.
im currently using your library as a dependency in json-rpc-core. thanks!
From #2 , there's a need for the API to cater to returning objects from serialization methods
The new API that I will be implementing in 0.2.0 is:
// current
jrs.requestObject('id', 'method'); // ---> object
jrs.request('id', 'method'); // ---> string
// proposed
jrs.request('id', 'method'); // ---> object
jrs.request('id', 'method').serialize(); // ---> string
This stops people who have already extended prototypes from using this library because this might override their methods.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.