Constructor
(protected) new State(data) → {State}
Creates a snapshot of some information.
Parameters:
Name | Type | Description |
---|---|---|
data |
Mixed | Input data. |
Properties:
Name | Type | Description |
---|---|---|
size |
Number | Size of state in bytes. |
@buffer |
Buffer | Byte-for-byte memory representation of state. |
@type |
String | Named type. |
@data |
Mixed | Local instance of the state. |
@id |
String | Unique identifier for this data. |
- Source:
Returns:
Resulting state.
- Type
- State
Extends
- EventEmitter
Methods
commit()
Increment the vector clock, broadcast all changes as a transaction.
- Source:
deserialize(input) → {State}
Take a hex-encoded input and convert to a State object.
Parameters:
Name | Type | Description |
---|---|---|
input |
String | [description] |
- Source:
Returns:
[description]
- Type
- State
fork() → {State}
- Source:
Returns:
- Type
- State
get(path) → {Mixed}
Retrieve a key from the State.
Parameters:
Name | Type | Description |
---|---|---|
path |
Path | Key to retrieve. |
- Source:
Returns:
- Type
- Mixed
render() → {String}
Compose a JSON string for network consumption.
- Source:
Returns:
JSON-encoded String.
- Type
- String
serialize(inputopt) → {Buffer}
Convert to Buffer.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
input |
Mixed |
<optional> |
Input to serialize. |
- Source:
Returns:
Store-able blob.
- Type
- Buffer
set(path) → {Mixed}
Set a key in the State to a particular value.
Parameters:
Name | Type | Description |
---|---|---|
path |
Path | Key to retrieve. |
- Source:
Returns:
- Type
- Mixed
toHTML()
Converts the State to an HTML document.
- Source:
toString() → {String}
Unmarshall an existing state to an instance of a Blob.
- Source:
Returns:
Serialized Blob.
- Type
- String
(static) fromJSON(input) → {State}
Marshall an input into an instance of a State. States have
absolute authority over their own domain, so choose your States wisely.
Parameters:
Name | Type | Description |
---|---|---|
input |
String | Arbitrary input. |
- Source:
Returns:
Resulting instance of the State.
- Type
- State