-
<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 |
Boolean
|
<optional>
|
false
|
When true, version 2 requests will set id to null instead of omitting it |
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> isPlainObject(obj)
-
Returns true if obj is a plain object (not null)
Parameters:
Name |
Type |
Description |
obj |
*
|
|
- Source:
-
Returns:
-
Type
-
Boolean
-
<static> once(fn)
-
Returns a function that can only be called once
Parameters:
Name |
Type |
Description |
fn |
function
|
|
- Source:
-
Returns:
-
Type
-
function
-
<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> pick(obj, keys)
-
Picks keys from obj
Parameters:
Name |
Type |
Description |
obj |
Object
|
|
keys |
Array.<String>
|
|
- Source:
-
Returns:
-
Type
-
Object
-
<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> toArray(obj)
-
Converts an object to an array
Parameters:
Name |
Type |
Description |
obj |
*
|
|
- Source:
-
Returns:
-
Type
-
Array
-
<static> toPlainObject(obj)
-
Converts an object to a plain object
Parameters:
Name |
Type |
Description |
obj |
*
|
|
- Source:
-
Returns:
-
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