@robodo/Dottle
Drop-in replacement for Dottle, works on node versions below 11.
AWS State Language to Graphviz DOT language
Install
npm i @robodo/dottle
API
AsyncIterator
read(input, [options]) ⇒ Accepts a ReadableStream, an AsyncIterator, an array or a string and returns an AsyncIterator.
Kind: global function
Returns: AsyncIterator
- Returns an AsyncIterator which yields Promises which resolve to parsed data.
Param | Type | Description |
---|---|---|
input |
ReadableStream | AsyncIterator | Array | string
|
Raw input data |
[options] | Object |
Optional options object. |
Example
for await (const result of read('{ "StartAt": "a", "States": { "a": { "Type": "Pass", "Next": "b" }, "b": { "Type": "Pass", "End": true } } }')) {
console.log(result);
}
// => digraph { a -> b }
WritableStream
readToStream(input, [options]) ⇒ Accepts a ReadableStream, an array or a string and returns a WritableStream. Stream output will be utf-8 text. Stream values will be delimited by a system-native newline escape character.
Kind: global function
Returns: WritableStream
- Returns a WritableStream Stream output will be utf-8 text. Stream values will be delimited by a system-native newline escape character.
Param | Type | Description |
---|---|---|
input |
ReadableStream | AsyncIterator | Array | string
|
Raw input data |
[options] | Object |
Optional options object. |
Example
readToStream('{ "StartAt": "a", "States": { "a": { "Type": "Pass", "Next": "b" }, "b": { "Type": "Pass", "End": true } } }').pipe(process.stdout);
// => digraph { a -> b }
Promise
readOne(input, [options]) ⇒ Accepts a ReadableStream, an AsyncIterator, an array or a string and returns a Promise which resolves to the first value of the stream.
Kind: global function
Returns: Promise
- Returns a Promise which resolves to the first value of the stream.
Param | Type | Description |
---|---|---|
input |
ReadableStream | AsyncIterator | Array | string
|
Raw input data |
[options] | Object |
Optional options object. |
Example
console.log(await readOne('{ "StartAt": "a", "States": { "a": { "Type": "Pass", "Next": "b" }, "b": { "Type": "Pass", "End": true } } }'));
// => digraph { a -> b }
Promise
readAll(input, [options]) ⇒ Accepts a ReadableStream, an AsyncIterator, an array or a string and returns a Promise which resolves to an array of all values.
Note: If a stream or iterator is passed to readAll
and it does not complete, the Promise returned by this function will never resolve.
Kind: global function
Returns: Promise
- Returns a Promise which resolves to an array of all values.
Param | Type | Description |
---|---|---|
input |
ReadableStream | AsyncIterator | Array | string
|
Raw input data |
[options] | Object |
Optional options object. |
Example
console.log(await readAll('{ "StartAt": "a", "States": { "a": { "Type": "Pass", "Next": "b" }, "b": { "Type": "Pass", "End": true } } }'));
// => digraph { a -> b }
License
MIT