Namespace: Utils

Utils

Namespaces

JSON
Request
Response

Methods


<static> generateId()

Generates a random UUID
Source:
Returns:
Type
String

<static> generateRequest(method, params [, id] [, options])

Generates a JSON-RPC 1.0 or 2.0 request
Parameters:
Name Type Argument Description
method String Name of method to call
params Array | Object Array of parameters passed to the method as specified, or an object of parameter names and corresponding value
id String | Number | null <optional>
Request ID can be a string, number, null for explicit notification or left out for automatic generation
options Object <optional>
Properties
Name Type Argument Default Description
version Number <optional>
2 JSON-RPC version to use (1 or 2)
notificationIdNull Number <optional>
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
generator function <optional>
Passed the request, and the options object and is expected to return a request ID
Source:
Throws:
If any of the parameters are invalid
Type
TypeError
Returns:
A JSON-RPC 1.0 or 2.0 request
Type
Object

<static> parseBody(stream [, options], callback)

Helper to parse a stream and interpret it as JSON
Parameters:
Name Type Argument Description
stream Stream Stream instance
options function <optional>
Optional options for JSON.parse
callback function
Source:

<static> parseStream(stream, options, onRequest)

Parses an incoming stream for requests using JSONStream
Parameters:
Name Type Description
stream Stream
options Object
onRequest function Called once for stream errors and an unlimited amount of times for valid requests
Source:

<static> response(error, result, id, version)

Generates a JSON-RPC 1.0 or 2.0 response
Parameters:
Name Type Description
error Object Error member
result Object Result member
id String | Number | null Id of request
version Number JSON-RPC version to use
Source:
Returns:
A JSON-RPC 1.0 or 2.0 response
Type
Object

<static> walk(holder, key, fn)

Recursively walk an object and apply a function on its members
Parameters:
Name Type Description
holder Object The object to walk
key String The key to look at
fn function The function to apply to members
Source:
Returns:
Type
Object