Sha256: a5160bc169d18a5979f17f3d063d475e4dcf74de8e25351e266c5ee700291d2a

Contents?: true

Size: 754 Bytes

Versions: 43

Compression:

Stored size: 754 Bytes

Contents

'use strict';
const stdin = process.stdin;

module.exports = () => {
	let ret = '';

	return new Promise(resolve => {
		if (stdin.isTTY) {
			resolve(ret);
			return;
		}

		stdin.setEncoding('utf8');

		stdin.on('readable', () => {
			let chunk;

			while ((chunk = stdin.read())) {
				ret += chunk;
			}
		});

		stdin.on('end', () => {
			resolve(ret);
		});
	});
};

module.exports.buffer = () => {
	const ret = [];
	let len = 0;

	return new Promise(resolve => {
		if (stdin.isTTY) {
			resolve(Buffer.concat([]));
			return;
		}

		stdin.on('readable', () => {
			let chunk;

			while ((chunk = stdin.read())) {
				ret.push(chunk);
				len += chunk.length;
			}
		});

		stdin.on('end', () => {
			resolve(Buffer.concat(ret, len));
		});
	});
};

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.21.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.20.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.19.1 node_modules/get-stdin/index.js
govuk_publishing_components-17.19.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.18.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.17.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.16.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.15.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.14.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.13.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.12.2 node_modules/get-stdin/index.js
govuk_publishing_components-17.12.1 node_modules/get-stdin/index.js
govuk_publishing_components-17.12.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.11.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.10.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.9.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.8.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.7.0 node_modules/get-stdin/index.js
govuk_publishing_components-17.6.1 node_modules/get-stdin/index.js