assertBytes()function
assertBytes(value: unknown, min = 0, max = Number.POSITIVE_INFINITY, caller: AnyCaller = assertBytes): asserts value is Bytes
| Param | Type | |
|---|---|---|
value | unknown | The value to assert. required |
min | unknown | Minimum allowed length (defaults to 0). Defaults to 0 |
max | unknown | Maximum allowed length (defaults to Infinity). Defaults to Number.POSITIVE_INFINITY |
caller | AnyCaller | Function to attribute a thrown error to (defaults to assertBytes itself). Defaults to assertBytes |
| Return | |
|---|---|
asserts value is Bytes |
| Throws | |
|---|---|
RequiredError | If value is not a byte sequence within the allowed length range. |
Assert that an unknown value is a Uint8Array byte sequence (optionally with a min/max length).
Examples
assertBytes(new Uint8Array([1, 2, 3]), 1, 8);