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

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

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

Source from the content-addressed store, hash-verified

1694// node_modules/get-stream/buffer-stream.js
1695var require_buffer_stream = __commonJS({
1696 "node_modules/get-stream/buffer-stream.js"(exports2, module2) {
1697 "use strict";
1698 var { PassThrough: PassThroughStream } = require("stream");
1699 module2.exports = (options) => {
1700 options = { ...options };
1701 const { array } = options;
1702 let { encoding } = options;
1703 const isBuffer2 = encoding === "buffer";
1704 let objectMode = false;
1705 if (array) {
1706 objectMode = !(encoding || isBuffer2);
1707 } else {
1708 encoding = encoding || "utf8";
1709 }
1710 if (isBuffer2) {
1711 encoding = null;
1712 }
1713 const stream4 = new PassThroughStream({ objectMode });
1714 if (encoding) {
1715 stream4.setEncoding(encoding);
1716 }
1717 let length = 0;
1718 const chunks = [];
1719 stream4.on("data", (chunk) => {
1720 chunks.push(chunk);
1721 if (objectMode) {
1722 length = chunks.length;
1723 } else {
1724 length += chunk.length;
1725 }
1726 });
1727 stream4.getBufferedValue = () => {
1728 if (array) {
1729 return chunks;
1730 }
1731 return isBuffer2 ? Buffer.concat(chunks, length) : chunks.join("");
1732 };
1733 stream4.getBufferedLength = () => length;
1734 return stream4;
1735 };
1736 }
1737});
1738
1739// node_modules/get-stream/index.js

Callers

nothing calls this directly

Calls 3

concatMethod · 0.80
onMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…