Comparing version 3.0.2 to 4.0.0
30
index.js
'use strict'; | ||
module.exports = function (cb) { | ||
var stdin = process.stdin; | ||
var ret = ''; | ||
if (process.stdin.isTTY) { | ||
if (stdin.isTTY) { | ||
cb(''); | ||
@@ -11,9 +12,13 @@ return; | ||
process.stdin.setEncoding('utf8'); | ||
stdin.setEncoding('utf8'); | ||
process.stdin.on('data', function (chunk) { | ||
ret += chunk; | ||
stdin.on('readable', function () { | ||
var chunk; | ||
while (chunk = stdin.read()) { | ||
ret += chunk; | ||
} | ||
}); | ||
process.stdin.on('end', function () { | ||
stdin.on('end', function () { | ||
cb(ret); | ||
@@ -24,6 +29,7 @@ }); | ||
module.exports.buffer = function (cb) { | ||
var stdin = process.stdin; | ||
var ret = []; | ||
var len = 0; | ||
if (process.stdin.isTTY) { | ||
if (stdin.isTTY) { | ||
cb(new Buffer('')); | ||
@@ -33,10 +39,14 @@ return; | ||
process.stdin.on('data', function (chunk) { | ||
ret.push(chunk); | ||
len += chunk.length; | ||
stdin.on('readable', function () { | ||
var chunk; | ||
while (chunk = stdin.read()) { | ||
ret.push(chunk); | ||
len += chunk.length; | ||
} | ||
}); | ||
process.stdin.on('end', function () { | ||
stdin.on('end', function () { | ||
cb(Buffer.concat(ret, len)); | ||
}); | ||
}; |
{ | ||
"name": "get-stdin", | ||
"version": "3.0.2", | ||
"version": "4.0.0", | ||
"description": "Easier stdin", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "node test.js && echo unicorns | node test2.js" | ||
"test": "node test.js && node test-buffer.js && echo unicorns | node test-real.js" | ||
}, | ||
@@ -19,0 +19,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1912
38