Skip to content

Commit

Permalink
version upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
huang-xiao-jian committed Dec 29, 2014
1 parent a5d3e57 commit 29c51a0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ var through = require('through-gulp');
function sample() {
// creating a stream through which each file will pass
var stream = through(function(file, encoding,callback) {
// do whatever necessary to process the file
if (file.isNull()) {
// do whatever necessary to process the file
if (file.isNull()) {

}
if (file.isBuffer()) {
}
if (file.isBuffer()) {

}
if (file.isStream()) {
}
if (file.isStream()) {

}
// just pipe data next, or just do nothing to process file later in flushFunction
// never forget callback to indicate that the file has been processed.
}
// just pipe data next, or just do nothing to process file later in flushFunction
// never forget callback to indicate that the file has been processed.
this.push(file);
callback();
},function(callback) {
Expand All @@ -99,16 +99,15 @@ function sample() {
module.exports = sample;
```


then use the plugin with gulp

```javascript
var gulp = require('gulp');
var sample = require('sample');
gulp.task('sample', function() {
return gulp.src(['source file'])
.pipe(sample())
.pipe(gulp.dest('file destiny'))
return gulp.src(['source file'])
.pipe(sample())
.pipe(gulp.dest('file destiny'))
});
```

Expand Down
20 changes: 11 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Expose function to generate transform stream
* @modules through-gulp
* @versions v0.3.7
* @versions v0.3.8
*/

/**
Expand Down Expand Up @@ -32,14 +32,6 @@ var util = require('util');
var stream = require('stream');
var through;

/**
* Define transform stream structure
* @constructor
*/
function Transform() {
stream.Transform.call(this, {objectMode: true});
}
util.inherits(Transform, stream.Transform);

// Default value for stream.Transform
function defaultTransformFunction(file, encoding, callback) {
Expand All @@ -57,6 +49,14 @@ function defaultFlushFunction(callback) {
* @returns {transformStream}
*/
through = function(transformFunction, flushFunction) {
/**
* Define transform stream structure
* @constructor
*/
function Transform() {
stream.Transform.call(this, {objectMode: true});
}
util.inherits(Transform, stream.Transform);

// use default function when not pass in
Transform.prototype._transform =
Expand All @@ -72,6 +72,7 @@ through = function(transformFunction, flushFunction) {
return new Transform();
};


/**
* shortcut method for map files
* @param {fileMap} map
Expand All @@ -84,6 +85,7 @@ through.map = function(map) {
});
};


/**
* shortcut method for filter files
* @param {fileFilter} filter
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "through-gulp",
"version": "0.3.7",
"version": "0.3.8",
"description": "A tiny wrapper around Node stream Transform, to simplify gulp plulgins development",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 29c51a0

Please sign in to comment.