Skip to content

Commit

Permalink
Breaking: Remove lodash.debounce & no longer utilize extra debounce o…
Browse files Browse the repository at this point in the history
…ptions (closes #31)
  • Loading branch information
phated committed Jun 29, 2017
1 parent dc1025f commit 21f08e3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 31 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Default: `[ 'add', 'change', 'unlink' ]`

##### other

Options are passed directly to [lodash.debounce][lodash-debounce] and [chokidar][chokidar], so all their options are supported. Any debounce-related options are documented in [lodash.debounce][lodash-debounce]. Any chokidar-related options are documented in [chokidar][chokidar].
Options are passed directly to [chokidar][chokidar].

## License

Expand All @@ -131,4 +131,3 @@ MIT
[node-glob]: https://github.com/isaacs/node-glob
[async-completion]: https://github.com/gulpjs/async-done#completion-and-error-resolution
[chokidar]: https://github.com/paulmillr/chokidar
[lodash-debounce]: https://lodash.com/docs#debounce
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var chokidar = require('chokidar');
var debounce = require('lodash.debounce');
var debounce = require('just-debounce');
var asyncDone = require('async-done');
var defaults = require('object.defaults');

Expand Down Expand Up @@ -57,7 +57,7 @@ function watch(glob, options, cb) {

var fn;
if (typeof cb === 'function') {
fn = debounce(onChange, opt.delay, opt);
fn = debounce(onChange, opt.delay);
}

function watchEvent(eventName) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"async-done": "^1.2.0",
"chokidar": "^1.4.3",
"lodash.debounce": "^4.0.6",
"just-debounce": "^1.0.0",
"object.defaults": "^1.0.0"
},
"devDependencies": {
Expand Down
26 changes: 0 additions & 26 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,32 +216,6 @@ describe('glob-watcher', function() {
});
});

it('passes options to lodash.debounce', function(done) {
var runs = 0;

watcher = watch(outGlob, { leading: true }, function(cb) {
runs++;
if (runs === 1) {
setTimeout(function() {
expect(runs).toEqual(1);
cb();
}, timeout * 3);
}
if (runs === 2) {
expect(runs).toEqual(2);
cb();
done();
}
});

// We default `ignoreInitial` to true, so always wait for `on('ready')`
watcher.on('ready', function() {
changeFile();
// Fires on the leading edge on the debounce
setTimeout(changeFile, timeout);
});
});

it('does not override default values with null values', function(done) {
watcher = watch(outGlob, { ignoreInitial: null }, function(cb) {
cb();
Expand Down

0 comments on commit 21f08e3

Please sign in to comment.