MCPcopy Create free account
hub / github.com/nodejs/node / bufferStartsWith

Function bufferStartsWith

deps/undici/src/lib/web/fetch/formdata-parser.js:513–525  ·  view source on GitHub ↗

* Checks if {@param buffer} starts with {@param start} * @param {Buffer} buffer * @param {Buffer} start * @param {{ position: number }} position

(buffer, start, position)

Source from the content-addressed store, hash-verified

511 * @param {{ position: number }} position
512 */
513function bufferStartsWith (buffer, start, position) {
514 if (buffer.length < start.length) {
515 return false
516 }
517
518 for (let i = 0; i < start.length; i++) {
519 if (start[i] !== buffer[position.position + i]) {
520 return false
521 }
522 }
523
524 return true
525}
526
527function parsingError (cause) {
528 return new TypeError('Failed to parse body as FormData.', { cause: new TypeError(cause) })

Callers 1

multipartFormDataParserFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected