MCPcopy
hub / github.com/di-sukharev/opencommit / "node_modules/get-stream/index.js"

Function "node_modules/get-stream/index.js"

out/cli.cjs:1741–1791  ·  view source on GitHub ↗
(exports2, module2)

Source from the content-addressed store, hash-verified

1739// node_modules/get-stream/index.js
1740var require_get_stream = __commonJS({
1741 "node_modules/get-stream/index.js"(exports2, module2) {
1742 "use strict";
1743 var { constants: BufferConstants } = require("buffer");
1744 var stream4 = require("stream");
1745 var { promisify } = require("util");
1746 var bufferStream = require_buffer_stream();
1747 var streamPipelinePromisified = promisify(stream4.pipeline);
1748 var MaxBufferError = class extends Error {
1749 constructor() {
1750 super("maxBuffer exceeded");
1751 this.name = "MaxBufferError";
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 });
1790 module2.exports.MaxBufferError = MaxBufferError;
1791 }
1792});
1793
1794// node_modules/merge-stream/index.js

Callers

nothing calls this directly

Calls 1

getStream3Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…