Skip to content

Commit

Permalink
Added a .debounce member to debounce (#21)
Browse files Browse the repository at this point in the history
* Added a .debounce member to debounce

Fixes #20.

* Mentioned newer imports in README.md
  • Loading branch information
Josh Goldberg authored and stephenmathieson committed Aug 14, 2018
1 parent e2ce8d2 commit cceb38c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ To execute any pending invocations and reset the timer:
window.onresize.flush();
```

Alternately, if using newer syntax:

```js
import { debounce } from "debounce";
```

## API

### debounce(fn, wait, [ immediate || false ])
Expand Down
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
* @param {Boolean} whether to execute at the beginning (`false`)
* @api public
*/

module.exports = function debounce(func, wait, immediate){
function debounce(func, wait, immediate){
var timeout, args, context, timestamp, result;
if (null == wait) wait = 100;

Expand Down Expand Up @@ -64,3 +63,8 @@ module.exports = function debounce(func, wait, immediate){

return debounced;
};

// Adds compatibility for ES modules
debounce.debounce = debounce;

module.exports = debounce;

0 comments on commit cceb38c

Please sign in to comment.