MCPcopy
hub / github.com/di-sukharev/opencommit / getStream3

Function getStream3

out/cli.cjs:1754–1786  ·  view source on GitHub ↗
(inputStream, options)

Source from the content-addressed store, hash-verified

1752 }
1753 };
1754 async function getStream3(inputStream, options) {
1755 if (!inputStream) {
1756 throw new Error("Expected a stream");
1757 }
1758 options = {
1759 maxBuffer: Infinity,
1760 ...options
1761 };
1762 const { maxBuffer } = options;
1763 const stream5 = bufferStream(options);
1764 await new Promise((resolve, reject) => {
1765 const rejectPromise = (error) => {
1766 if (error && stream5.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
1767 error.bufferedData = stream5.getBufferedValue();
1768 }
1769 reject(error);
1770 };
1771 (async () => {
1772 try {
1773 await streamPipelinePromisified(inputStream, stream5);
1774 resolve();
1775 } catch (error) {
1776 rejectPromise(error);
1777 }
1778 })();
1779 stream5.on("data", () => {
1780 if (stream5.getBufferedLength() > maxBuffer) {
1781 rejectPromise(new MaxBufferError());
1782 }
1783 });
1784 });
1785 return stream5.getBufferedValue();
1786 }
1787 module2.exports = getStream3;
1788 module2.exports.buffer = (stream5, options) => getStream3(stream5, { ...options, encoding: "buffer" });
1789 module2.exports.array = (stream5, options) => getStream3(stream5, { ...options, array: true });

Calls 2

rejectPromiseFunction · 0.85
onMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…