Skip to content

Commit 248e870

Browse files
committed
docs: update readme to reflect repeatAfterRatio
1 parent 503a257 commit 248e870

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ const fragments = encoder.getAllPartsUr(2); // Ratio of fountain parts compared
760760
// Keep generating new parts, until a condition is met; for example, the user exits the page, or clicks "DONE"
761761
while (!stop) {
762762
// get the next part in the sequence
763-
let part = encoder.nextPart().toString();
763+
let part = encoder.nextPartUr().toString();
764764

765765
// Get the UR string part that contains data from the original UR data
766766
// the part looks like this:
@@ -849,6 +849,7 @@ The `UrFountainEncoder` class is used to encode data into Multipart URs. It take
849849
- `maxFragmentLength`: The maximum size of the CBOR data encoded in the UR. This determines the size of one UR, and the size of the QR code will increase depending on it. However, it is not the direct size; instead, more data is added on top of that size. Default is 100.
850850
- `minFragmentLength`: The minimum size of the CBOR data encoded in the UR. Default is 10.
851851
- `firstSeqNum`: The starting sequence number. The encoder will give you direct parts of the original UR until the sequence number reaches the total number of fragments. Then it will start to spit out mixed blocks or fragments using the fountain encoder. This ensures that you don't have to wait for the original part to repeat, and every next fountain part contains a few of the original parts. You can get lucky and decode the whole original payload without waiting to re-read all the parts again if you miss a QR code. Default is 0.
852+
- `repeatAfterRatio`: The ratio of part to reset the sequence number and start from the beginning if it goes over `fragmentCount * repeatAfterRatio`. . Default is 2. `0` means fountain encoder `.nextPartUr()` will generate a new part forever.
852853

853854
**Example Usage:**
854855

@@ -861,10 +862,10 @@ const testPayload = {
861862
};
862863

863864
const userUr = UR.fromData({ type: "user", payload: testPayload });
864-
const encoder = new UrFountainEncoder(userUr, 5); // maxFragmentLength: 5, minFragmentLength: 10, firstSeqNum: 0
865+
const encoder = new UrFountainEncoder(userUr, 5); // maxFragmentLength: 5, minFragmentLength: 10, firstSeqNum: 0, repeatAfterRatio: 2
865866

866867
while (!stop) {
867-
let part = encoder.nextPart().toString();
868+
let part = encoder.nextPartUr().toString();
868869
displayPart(part);
869870
}
870871
```

0 commit comments

Comments
 (0)