(source: unknown)
| 14 | } |
| 15 | |
| 16 | export function validateBinaryLike(source: unknown): Uint8Array { |
| 17 | if (typeof source === "string") { |
| 18 | return encoder.encode(source); |
| 19 | } else if (source instanceof Uint8Array) { |
| 20 | return source; |
| 21 | } else if (source instanceof ArrayBuffer) { |
| 22 | return new Uint8Array(source); |
| 23 | } |
| 24 | throw new TypeError( |
| 25 | `Cannot validate the input as it must be a Uint8Array, a string, or an ArrayBuffer: received a value of the type ${ |
| 26 | getTypeName(source) |
| 27 | }`, |
| 28 | ); |
| 29 | } |
no test coverage detected