MCPcopy Create free account
hub / github.com/angular/dev-infra / validateHandler

Function validateHandler

github-actions/browserstack/set-browserstack-env.js:1423–1451  ·  view source on GitHub ↗
(handler, method, upgrade)

Source from the content-addressed store, hash-verified

1421 return buffer instanceof Uint8Array || Buffer.isBuffer(buffer);
1422 }
1423 function validateHandler(handler, method, upgrade) {
1424 if (!handler || typeof handler !== "object") {
1425 throw new InvalidArgumentError("handler must be an object");
1426 }
1427 if (typeof handler.onConnect !== "function") {
1428 throw new InvalidArgumentError("invalid onConnect method");
1429 }
1430 if (typeof handler.onError !== "function") {
1431 throw new InvalidArgumentError("invalid onError method");
1432 }
1433 if (typeof handler.onBodySent !== "function" && handler.onBodySent !== void 0) {
1434 throw new InvalidArgumentError("invalid onBodySent method");
1435 }
1436 if (upgrade || method === "CONNECT") {
1437 if (typeof handler.onUpgrade !== "function") {
1438 throw new InvalidArgumentError("invalid onUpgrade method");
1439 }
1440 } else {
1441 if (typeof handler.onHeaders !== "function") {
1442 throw new InvalidArgumentError("invalid onHeaders method");
1443 }
1444 if (typeof handler.onData !== "function") {
1445 throw new InvalidArgumentError("invalid onData method");
1446 }
1447 if (typeof handler.onComplete !== "function") {
1448 throw new InvalidArgumentError("invalid onComplete method");
1449 }
1450 }
1451 }
1452 function isDisturbed(body) {
1453 return !!(body && (stream.isDisturbed(body) || body[kBodyUsed]));
1454 }

Callers 1

constructorMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected