MCPcopy Index your code
hub / github.com/nodejs/node / assertBufferSource

Function assertBufferSource

lib/internal/modules/helpers.js:428–442  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

426 * @returns {void}
427 */
428function 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
444let DECODER = null;
445

Callers 2

stringifyFunction · 0.85
translators.jsFile · 0.85

Calls 1

lazyTypesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…