Source - PatchSourceBuilder
Source.PatchSourceBuilderA helper class to build a patch source that modify or update a "base" stream.
Example
// Create a datastream which whose value is a (writeable) patch applied to a base stream
export default new SourceBuilder("Patch")
.patch(base_stream)
.toTemplate()
Type parameters
Name | Type |
---|---|
T | extends EastType |
Hierarchy
-
Builder
↳
PatchSourceBuilder
Source
conflictStream
▸ conflictStream():
Stream
<PatchType
>
Return the
Stream containing any conflicts that occurred when attempting to apply the patch.Conflicts can occur when:
- a key is inserted when it already exists in the base
- a key is updated that doesn't exist in the base, or has an unexpected value in the base
- a key is deleted when it doesn't exist in the base
The stream will be empty when there are no conflicts
Returns
Stream
<PatchType
>
Example
// Return the datastream containing any patch conflicts
const source = new SourceBuilder("Patch")
.patch(base_stream)
.conflictStream()
outputStream
▸ outputStream():
Stream
Return the
Stream containing the patched output.Returns
Stream
Example
// Return the datastream which whose value is a (writeable) patch applied to a base stream
const source = new SourceBuilder("Patch")
.patch(base_stream)
.outputStream()
toTask
▸ toTask(): PatchSourceTaskDescription
& { task_type
: "source"
}
Return a TaskDescriptions built by this builder.
Returns
PatchSourceTaskDescription
& { task_type
: "source"
}
Example
// Create a datastream which whose value is a (writeable) patch applied to a base stream
const task = new SourceBuilder("Patch")
.patch(base_stream)
.toTask()
toTemplate
▸ toTemplate():
Template
Return a
Template fragment containing the Streams and TaskDescriptions built by this builder.Returns
Template
Example
// Create a datastream which whose value is a (writeable) patch applied to a base stream
const template = new SourceBuilder("Patch")
.patch(base_stream)
.toTemplate()
Overrides
Builder.toTemplate
value
▸ value(value
):
PatchSourceBuilder
Initialize the patch stream with a value.
Parameters
Name | Type | Description |
---|---|---|
value | ValueTypeOf <PatchType > | a default patch to apply |
Returns
PatchSourceBuilder
a new
PatchSourceBuilderExample
// Create a datastream which whose value is a base stream patched with an additional inserted key-value pair
const source = SourceBuilder("Patch")
.patch(base_stream)
.value(new Map([["key", variant("Insert", "value")]]))