gulp-batch
Advanced tools
Comparing version 0.1.0 to 0.2.0
11
index.js
@@ -27,4 +27,11 @@ 'use strict'; | ||
function async() { | ||
holdOn = false; | ||
brace(); | ||
if (opts.debounce) { | ||
setTimeout(function () { | ||
holdOn = false; | ||
brace(); | ||
}, opts.debounce); | ||
} else { | ||
holdOn = false; | ||
brace(); | ||
} | ||
} | ||
@@ -31,0 +38,0 @@ |
{ | ||
"name": "gulp-batch", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Event batcher for gulp-watcher", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -45,3 +45,3 @@ # [gulp](https://github.com/gulpjs/gulp)-batch [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url] | ||
* `debounce` - __Not implemented yet__ Minimal interval between calling callback (default: `0`) | ||
* `debounce` - Minimal interval between calling callback after `done` (only works with async callback) (default: `0`) | ||
* `limit` - Maximum events number, that gets into one batch (default: `undefined` - unlimited) | ||
@@ -48,0 +48,0 @@ * `timeout` - Interval in milliseconds, that counts as "no more events will arrive" (default: `200`) |
@@ -61,13 +61,10 @@ /* global describe, it */ | ||
function (events, cb) { | ||
receiver('three'); | ||
receiver('four'); | ||
receiver('five'); | ||
receiver('two'); | ||
setTimeout(function () { | ||
cb(); | ||
receiver('six'); | ||
receiver('seven'); | ||
receiver('three'); | ||
}, 15); | ||
}, | ||
function (events) { | ||
assert.equal(events.length, 5); | ||
assert.equal(events.length, 2); | ||
done(); | ||
@@ -80,5 +77,24 @@ } | ||
receiver('one'); | ||
receiver('two'); | ||
}); | ||
it('should support debounce option', function (done) { | ||
var iterator = async.iterator([ | ||
function (events, cb) { | ||
receiver('two'); | ||
setTimeout(function () { | ||
cb(); | ||
setTimeout(receiver.bind(null, 'three'), 15); | ||
}, 15); | ||
}, | ||
function (events) { | ||
assert.equal(events.length, 2); | ||
done(); | ||
} | ||
]); | ||
var receiver = batch({ timeout: 10, debounce: 10 }, function (events, cb) { | ||
iterator = iterator(events, cb); | ||
}); | ||
receiver('one'); | ||
}); | ||
it('should throw, if we provide invalid callback', function () { | ||
@@ -85,0 +101,0 @@ assert.throws(batch, /Provided callback is not a function/); |
Sorry, the diff of this file is not supported yet
37711
169