PHP 7.4.33
Preview: buffer-stream.js Size: 894 B
/var/www/cvr-leads.bitkit.dk/httpdocs/node_modules/get-stream/buffer-stream.js
'use strict';
const {PassThrough: PassThroughStream} = require('stream');

module.exports = options => {
	options = {...options};

	const {array} = options;
	let {encoding} = options;
	const isBuffer = encoding === 'buffer';
	let objectMode = false;

	if (array) {
		objectMode = !(encoding || isBuffer);
	} else {
		encoding = encoding || 'utf8';
	}

	if (isBuffer) {
		encoding = null;
	}

	const stream = new PassThroughStream({objectMode});

	if (encoding) {
		stream.setEncoding(encoding);
	}

	let length = 0;
	const chunks = [];

	stream.on('data', chunk => {
		chunks.push(chunk);

		if (objectMode) {
			length = chunks.length;
		} else {
			length += chunk.length;
		}
	});

	stream.getBufferedValue = () => {
		if (array) {
			return chunks;
		}

		return isBuffer ? Buffer.concat(chunks, length) : chunks.join('');
	};

	stream.getBufferedLength = () => length;

	return stream;
};

Directory Contents

Dirs: 0 × Files: 6
Name Size Perms Modified Actions
894 B lrw-r--r-- 2025-03-11 10:09:12
Edit Download
3.58 KB lrw-r--r-- 2025-03-11 10:09:12
Edit Download
1.45 KB lrw-r--r-- 2025-03-11 10:09:12
Edit Download
1.09 KB lrw-r--r-- 2025-03-11 10:09:12
Edit Download
819 B lrw-r--r-- 2025-03-11 10:09:12
Edit Download
4.10 KB lrw-r--r-- 2025-03-11 10:09:12
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).