Comparing version 0.10.0 to 1.0.0
@@ -586,1 +586,20 @@ // Load modules | ||
}; | ||
exports.readStream = function (stream, callback) { | ||
var result = ''; | ||
stream.on('readable', function () { | ||
var read = stream.read(); | ||
if (read) { | ||
result += read.toString(); | ||
} | ||
}); | ||
stream.once('end', function () { | ||
callback(result); | ||
}); | ||
}; |
{ | ||
"name": "hoek", | ||
"description": "General purpose node utilities", | ||
"version": "0.10.0", | ||
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)", | ||
"contributors":[ | ||
"Van Nguyen <the.gol.effect@gmail.com>" | ||
], | ||
"version": "1.0.0", | ||
"repository": "git://github.com/spumko/hoek", | ||
@@ -20,4 +16,3 @@ "main": "index", | ||
"devDependencies": { | ||
"lab": "0.1.x", | ||
"complexity-report": "0.x.x" | ||
"lab": "0.2.x" | ||
}, | ||
@@ -24,0 +19,0 @@ "scripts": { |
@@ -41,2 +41,4 @@ <a href="https://github.com/spumko"><img src="https://raw.github.com/spumko/spumko/master/images/from.png" align="right" /></a> | ||
* [loadDirModules](#loadDirModulespath-excludefiles-target "loaddirmodules") | ||
* [Streams](#streams "Streams") | ||
* [readStream](#readstream "readStream") | ||
@@ -47,3 +49,3 @@ | ||
The *Hoek* general purpose node utilities library is used to aid in a variety of manners. It comes with useful methods for Arrays (clone, merge, applyToDefaults), Objects (removeKeys, copy), Asserting and more. | ||
The *Hoek* general purpose node utilities library is used to aid in a variety of manners. It comes with useful methods for Arrays (clone, merge, applyToDefaults), Objects (removeKeys, copy), Asserting and more. | ||
@@ -69,3 +71,3 @@ For example, to use Hoek to set configuration with default options: | ||
This method is used to clone an object or an array. A *deep copy* is made (duplicates everything, including values that are objects). | ||
This method is used to clone an object or an array. A *deep copy* is made (duplicates everything, including values that are objects). | ||
@@ -177,3 +179,3 @@ ```javascript | ||
### matchKeys(obj, keys) | ||
### matchKeys(obj, keys) | ||
@@ -198,3 +200,3 @@ Find which keys are present | ||
var array = [1, 2, 3]; | ||
var target = [4, 5]; | ||
var target = [4, 5]; | ||
@@ -232,3 +234,3 @@ var flattenedArray = Hoek.flatten(array, target) // results in [4, 5, 1, 2, 3]; | ||
### inheritAsync(self, obj, keys) | ||
### inheritAsync(self, obj, keys) | ||
@@ -259,3 +261,3 @@ Inherits a selected set of methods from an object, wrapping functions in asynchronous syntax and catching errors | ||
target.a(function(err, result){console.log(result)} // returns 'a!' | ||
target.a(function(err, result){console.log(result)} // returns 'a!' | ||
@@ -288,3 +290,3 @@ target.c(function(err, result){console.log(result)} // returns undefined | ||
example : | ||
example : | ||
@@ -438,3 +440,3 @@ | ||
### loadDirModules(path, excludeFiles, target) | ||
### loadDirModules(path, excludeFiles, target) | ||
@@ -444,3 +446,15 @@ Loads modules from a given path; option to exclude files (array). | ||
# Streams | ||
### readStream | ||
Read an entire stream buffer into a string | ||
```javascript | ||
readStream(inputStream, function (outputString) { | ||
... | ||
}); | ||
``` | ||
// Load modules | ||
var Lab = require('lab'); | ||
var Stream = require('stream'); | ||
var Hoek = require('../lib'); | ||
@@ -1083,3 +1084,31 @@ | ||
}); | ||
describe('#readStream', function () { | ||
it('reads a stream and provides output to callback', function (done) { | ||
var readable = new Stream.Readable(); | ||
readable._read = function () { | ||
this.push('hello'); | ||
this.push(' '); | ||
readable._read = function () { | ||
this.push('world'); | ||
this.push(null); | ||
return false; | ||
}; | ||
return true; | ||
}; | ||
Hoek.readStream(readable, function (result) { | ||
expect(result).to.equal('hello world'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
101194
1
16
1357
1
451
2
1