Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Node.js (node 11.12.0) sample

process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var remainder = ''
process.stdin.on('data', function (chunk) {
	var lines = chunk.toString().split('
');
	lines.unshift(remainder + lines.shift());
	remainder = lines.pop();
	lines.forEach(function(line) {
		if (line === '42') {
			process.exit();
		}
		process.stdout.write(line+'
');
	});
});
Source by ideone.com #
 
PREVIOUS NEXT
Tagged: #sample
ADD COMMENT
Topic
Name
2+1 =