Skip to content

Commit

Permalink
Added explanation about the debounce time.
Browse files Browse the repository at this point in the history
  • Loading branch information
andresberrios committed Mar 13, 2014
1 parent 50cadba commit 540237a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ aggregate = require('gulp-aggregate');
concat = require('gulp-concat');

fileStreamWithNoEndEvent = watch({glob: 'watchedScripts/*.js'})
.pipe(aggregate(function(fileStreamWithEndEvent) {
.pipe(aggregate({debounce: 10}, function(fileStreamWithEndEvent) {
return fileStreamWithEndEvent
.pipe(concat('concatenated.js'))
.pipe(gulp.dest('public/scripts'));
}))
```
```

The default `debounce` time is 50ms. After `debounce` milliseconds without
receiving data, the `callback` function will get called with the new aggregated stream.
1 change: 1 addition & 0 deletions example.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ gulp.src 'files/*.js'
.pipe aggregate debounce: 10, (files) ->
files.pipe es.mapSync (file) ->
gutil.log gutil.colors.magenta file.path
.on 'end', -> gutil.log gutil.colors.magenta 'End event called'
.pipe es.mapSync (file) ->
gutil.log file.path
4 changes: 3 additions & 1 deletion example.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = (opts, callback) ->
unless isFunction callback
throw new Error "Invalid callback provided: #{callback}"

opts.debounce ?= 200
opts.debounce ?= 50

debouncedCallback = null
if opts.debounce is 0
Expand Down
2 changes: 1 addition & 1 deletion index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 540237a

Please sign in to comment.