* Asserts that the given body is a buffer source (either a string, array buffer, or typed array). * Throws an error if the body is not a buffer source. * @param {string | ArrayBufferView | ArrayBuffer} body - The body to check. * @param {boolean} allowString - Whether or not to allow a string as
(body, allowString, hookName)
| 426 | * @returns {void} |
| 427 | */ |
| 428 | function assertBufferSource(body, allowString, hookName) { |
| 429 | if (allowString && typeof body === 'string') { |
| 430 | return; |
| 431 | } |
| 432 | const { isArrayBufferView, isAnyArrayBuffer } = lazyTypes(); |
| 433 | if (isArrayBufferView(body) || isAnyArrayBuffer(body)) { |
| 434 | return; |
| 435 | } |
| 436 | throw new ERR_INVALID_RETURN_PROPERTY_VALUE( |
| 437 | `${allowString ? 'string, ' : ''}array buffer, or typed array`, |
| 438 | hookName, |
| 439 | 'source', |
| 440 | body, |
| 441 | ); |
| 442 | } |
| 443 | |
| 444 | let DECODER = null; |
| 445 |
no test coverage detected
searching dependent graphs…