* Convert a chunk (string or Uint8Array) to Uint8Array. * Strings are UTF-8 encoded. * @param {Uint8Array|string} chunk * @returns {Uint8Array}
(chunk)
| 97 | * @returns {Uint8Array} |
| 98 | */ |
| 99 | function toUint8Array(chunk) { |
| 100 | if (typeof chunk === 'string') { |
| 101 | return encoder.encode(chunk); |
| 102 | } |
| 103 | if (!isUint8Array(chunk)) { |
| 104 | throw new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Uint8Array'], chunk); |
| 105 | } |
| 106 | return chunk; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Check if all chunks in an array are already Uint8Array (no strings). |
no test coverage detected
searching dependent graphs…