Skip to content

Commit

Permalink
extend options
Browse files Browse the repository at this point in the history
  • Loading branch information
EParisot committed Sep 3, 2023
1 parent c8789cc commit b96fc57
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class Transaction<T> {
/// ```dart
/// var c = Transaction.terminated(p.inputStream, Uint8List.fromList([13, 10]));
/// ```
static Transaction<Uint8List> terminated(Stream<Uint8List> stream,
Uint8List terminator, int maxLen: 1024, bool stripTerminator: true) {
static Transaction<Uint8List> terminated(
Stream<Uint8List> stream, Uint8List terminator,
{int maxLen: 1024, bool stripTerminator: true}) {
return Transaction<Uint8List>(
stream,
TerminatedTransformer.broadcast(
Expand All @@ -56,9 +57,12 @@ class Transaction<T> {
/// Transaction.magicHeader(p.inputStream, Uint8List.fromList([65,65,65])); // expects magic header AAA and then byte of length.
/// ```
static Transaction<Uint8List> magicHeader(
Stream<Uint8List> stream, List<int> header) {
Stream<Uint8List> stream, List<int> header,
{int maxLen: 1024}) {
return Transaction<Uint8List>(
stream, MagicHeaderAndLengthByteTransformer.broadcast(header: header));
stream,
MagicHeaderAndLengthByteTransformer.broadcast(
header: header, maxLen: maxLen));
}

/// Create a transaction that transforms the incoming stream into
Expand All @@ -68,9 +72,14 @@ class Transaction<T> {
/// var c = Transaction.stringTerminated(p.inputStream, Uint8List.fromList([13, 10]));
/// ```
static Transaction<String> stringTerminated(
Stream<Uint8List> stream, Uint8List terminator) {
Stream<Uint8List> stream, Uint8List terminator,
{int maxLen: 1024, bool stripTerminator: true}) {
return Transaction<String>(
stream, TerminatedStringTransformer.broadcast(terminator: terminator));
stream,
TerminatedStringTransformer.broadcast(
terminator: terminator,
maxLen: maxLen,
stripTerminator: stripTerminator));
}

/// Transaction Constructor, pass it the untransformed input stream and
Expand Down

0 comments on commit b96fc57

Please sign in to comment.