blue-frog-stream
parse and reduce the batch processing of JSON-RPC2.0 request/respponse.
see example
example
http server
var rpc = var response = var rpcError = var api = { var batch = true if err process else result return batch} var app = http { } { return response} { return response} { return response}
http client
var rpc = var request = var maap = var batch = rpcrequestvar hyp = hyperquest batch var req1 = var req2 = requestvar req3 = maapmaap batchbatchbatch { console} { return map_: {} { if 'id' in req && reqid !== null return !! thismap_reqid = onSuccess else return false } { if ! thismap_resid return else thismap_residdataresult done } }
api
var rpc =
create a request batch stream. transform stream.
var batch = doJSONstringify
doJSONstringify
: boolean. if this value truthy, then export data is jsonString.
var batch = truebatchbatch batchbatchbatchbatch
create a request parse stream. readable stream.
var parse = jsonRpc2RequestObject
jsonRpc2RequestObject
: object or array.
var parse = jsonrpc: "2.0" id: 123 method: "sum" params: 123 jsonrpc: "2.0" id: null method: "add" params: 4 foo: "bar" jsonrpc: "2.0" id: 456 method: "getResult" parse
create a response batch stream. transform stream.
var batch = doJSONstringify
doJSONstringify
: boolean. if this value truthy, then export data is jsonString.
var batch = truebatchbatch batchbatchbatchbatch
create a response parse stream. readable stream.
var parse = jsonRpc2RequestObject
jsonRpc2RequestObject
: object or array.
var parse = jsonrpc: "2.0" id: 123 result: amount: 6 jsonrpc: "2.0" id: null error: code: -32602 message: "Invalid params" data: "TypeError: \"hoge\" is not \"number\"" jsonrpc: "2.0" id: 456 result: amount: 6) parse
see also
licence
MIT