Comparing version
var fs = require('fs'); | ||
var isString = require('lodash.isstring'); | ||
@@ -10,11 +11,3 @@ var Transformer = require('./transform'); | ||
if (!isReadStream(input)) { | ||
throw new Error('No input stream specified!'); | ||
} | ||
if (!isWriteStream(output)) { | ||
throw new Error('No output stream specified!'); | ||
} | ||
if (typeof input === 'string') { | ||
if (isString(input)) { | ||
input = fs.createReadStream(input); | ||
@@ -26,3 +19,3 @@ } | ||
if (output !== 'string') { | ||
if (typeof output === 'string') { | ||
if (isString(output)) { | ||
stream = fs.createWriteStream(output); | ||
@@ -36,2 +29,10 @@ } else { | ||
if (!isReadStream(input)) { | ||
throw new Error('No input stream specified!'); | ||
} | ||
if (!isWriteStream(stream)) { | ||
throw new Error('No output stream specified!'); | ||
} | ||
var transformer = new Transformer(); | ||
@@ -62,12 +63,14 @@ | ||
function isReadStream(rs){ | ||
return isStream(rs, process.stdin, '_read'); | ||
function isReadStream(obj) { | ||
// some streams are readable but do not have `read()`, however | ||
// we can reliably detect readability by testing for `resume()` | ||
return isStream(obj) && typeof obj.resume === 'function'; | ||
} | ||
function isWriteStream(ws){ | ||
return isStream(ws, process.stdout, '_write'); | ||
function isWriteStream(obj) { | ||
return isStream(obj) && typeof obj.write === 'function'; | ||
} | ||
function isStream(st, sys, prop){ | ||
return st && (st === sys|| typeof(st[prop]) === 'function' || typeof(st) === 'string'); | ||
} | ||
function isStream(obj) { | ||
return obj && typeof obj.pipe === 'function'; | ||
} |
@@ -0,0 +0,0 @@ var Stream = require('readable-stream'); |
{ | ||
"name": "neek", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A simple implementation of *nix uniq in NodeJS to take advantage of streaming", | ||
@@ -34,21 +34,22 @@ "author": { | ||
"dependencies": { | ||
"farmhash": "^1.1.1", | ||
"hashes": "0.1.3", | ||
"farmhash": "^1.2.1", | ||
"hashes": "0.1.4", | ||
"lodash.isstring": "4.0.1", | ||
"minimist": "1.2.0", | ||
"readable-stream": "2.1.4" | ||
"readable-stream": "2.1.5" | ||
}, | ||
"devDependencies": { | ||
"grunt": "0.4.5", | ||
"grunt": "1.0.1", | ||
"grunt-cli": "1.2.0", | ||
"grunt-codeclimate-reporter": "1.1.2", | ||
"grunt-codeclimate-reporter": "1.2.1", | ||
"grunt-contrib-clean": "1.0.0", | ||
"grunt-contrib-jshint": "1.0.0", | ||
"grunt-mkdir": "1.0.0", | ||
"grunt-mocha-istanbul": "4.0.2", | ||
"grunt-mocha-test": "0.12.7", | ||
"istanbul": "0.4.3", | ||
"jshint": "2.9.2", | ||
"mocha": "2.4.5", | ||
"should": "8.3.2" | ||
"grunt-mocha-istanbul": "5.0.2", | ||
"grunt-mocha-test": "0.13.2", | ||
"istanbul": "0.4.5", | ||
"jshint": "2.9.3", | ||
"mocha": "3.1.0", | ||
"should": "11.1.0" | ||
} | ||
} |
@@ -0,0 +0,0 @@ Neek [](https://travis-ci.org/zackehh/neek) [](https://codeclimate.com/github/zackehh/neek) [](https://codeclimate.com/github/zackehh/neek) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
37927
88.84%20
17.65%1
-50%5
25%146
-55.35%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
Updated
Updated
Updated