toPromise() — astro Function Reference
Architecture documentation for the toPromise() function in test-utils.js from the astro codebase.
Entity Profile
Dependency Diagram
graph TD faadc1fc_e8ff_8aac_bad0_4c2e6c17fbde["toPromise()"] b0be4d0c_86b6_a283_f2af_003189bfd572["test-utils.js"] faadc1fc_e8ff_8aac_bad0_4c2e6c17fbde -->|defined in| b0be4d0c_86b6_a283_f2af_003189bfd572 37bee138_718e_22c5_b294_37b0235244a2["createRequestAndResponse()"] 37bee138_718e_22c5_b294_37b0235244a2 -->|calls| faadc1fc_e8ff_8aac_bad0_4c2e6c17fbde style faadc1fc_e8ff_8aac_bad0_4c2e6c17fbde fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/test/units/test-utils.js lines 66–85
function toPromise(res) {
return new Promise((resolve) => {
// node-mocks-http doesn't correctly handle non-Buffer typed arrays,
// so override the write method to fix it.
const write = res.write;
res.write = function (data, encoding) {
if (ArrayBuffer.isView(data) && !Buffer.isBuffer(data)) {
data = Buffer.from(data.buffer);
}
if (typeof data === 'string') {
data = Buffer.from(data);
}
return write.call(this, data, encoding);
};
res.on('end', () => {
let chunks = res._getChunks();
resolve(chunks);
});
});
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does toPromise() do?
toPromise() is a function in the astro codebase, defined in packages/astro/test/units/test-utils.js.
Where is toPromise() defined?
toPromise() is defined in packages/astro/test/units/test-utils.js at line 66.
What calls toPromise()?
toPromise() is called by 1 function(s): createRequestAndResponse.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free