(object, convertBytesToJSValue, instance, getInternalState)
| 6933 | } |
| 6934 | __name(mixinBody, "mixinBody"); |
| 6935 | function consumeBody(object, convertBytesToJSValue, instance, getInternalState) { |
| 6936 | try { |
| 6937 | webidl.brandCheck(object, instance); |
| 6938 | } catch (e) { |
| 6939 | return Promise.reject(e); |
| 6940 | } |
| 6941 | object = getInternalState(object); |
| 6942 | if (bodyUnusable(object)) { |
| 6943 | return Promise.reject(new TypeError("Body is unusable: Body has already been read")); |
| 6944 | } |
| 6945 | const promise = Promise.withResolvers(); |
| 6946 | const errorSteps = promise.reject; |
| 6947 | const successSteps = /* @__PURE__ */ __name((data) => { |
| 6948 | try { |
| 6949 | promise.resolve(convertBytesToJSValue(data)); |
| 6950 | } catch (e) { |
| 6951 | errorSteps(e); |
| 6952 | } |
| 6953 | }, "successSteps"); |
| 6954 | if (object.body == null) { |
| 6955 | successSteps(Buffer.allocUnsafe(0)); |
| 6956 | return promise.promise; |
| 6957 | } |
| 6958 | fullyReadBody(object.body, successSteps, errorSteps); |
| 6959 | return promise.promise; |
| 6960 | } |
| 6961 | __name(consumeBody, "consumeBody"); |
| 6962 | function bodyUnusable(object) { |
| 6963 | const body = object.body; |
no test coverage detected