From 8effb286d22afb17652d4b1221beb4c765e34428 Mon Sep 17 00:00:00 2001 From: dhershman1 Date: Wed, 15 Jan 2020 09:30:33 -0500 Subject: [PATCH 1/4] new dist files --- dist/debounce.min.js | 2 +- dist/vue-debounce.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/debounce.min.js b/dist/debounce.min.js index 04f6276..1a9f83f 100644 --- a/dist/debounce.min.js +++ b/dist/debounce.min.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).debounce=n()}(this,function(){"use strict";return function(t,e){function n(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];clearTimeout(o),(o=setTimeout(function(){o=null,t.apply(void 0,e)},i))||t.apply(void 0,e)}var o=null,i="number"==typeof e?e:function(e){var n=String(e).split(/(ms|s)/i),t=n[0],o=n[1];void 0===o&&(o="ms");var i={ms:1,s:1e3}[o];if(!i)throw new Error("Time type must but either ms or s");return Number(t)*i}(e);return n.cancel=function(){clearTimeout(o),o=null},n}}); +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).debounce=n()}(this,function(){"use strict";return function(t,e){function n(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];clearTimeout(f),(f=setTimeout(function(){f=null,t.apply(void 0,e)},l))||t.apply(void 0,e)}var o,i,u,f=null,l="number"==typeof e?e:(o=String(e).split(/(ms|s)/i),i=o[0],void 0===(u=o[1])&&(u="ms"),Number(i)*{ms:1,s:1e3}[u]);return n.cancel=function(){clearTimeout(f),f=null},n}}); diff --git a/dist/vue-debounce.min.js b/dist/vue-debounce.min.js index bb24777..272b669 100644 --- a/dist/vue-debounce.min.js +++ b/dist/vue-debounce.min.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).vueDebounce={})}(this,function(e){"use strict";function d(t,e){function n(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];clearTimeout(o),(o=setTimeout(function(){o=null,t.apply(void 0,e)},r))||t.apply(void 0,e)}var o=null,r="number"==typeof e?e:function(e){var n=String(e).split(/(ms|s)/i),t=n[0],o=n[1];void 0===o&&(o="ms");var r={ms:1,s:1e3}[o];if(!r)throw new Error("Time type must but either ms or s");return Number(t)*r}(e);return n.cancel=function(){clearTimeout(o),o=null},n}function s(e,n){var t=(e.getNamedItem("debounce-events")||{}).value;void 0===t&&(t=!1);function o(e){return e.map(function(e){return e.toLowerCase()})}return t?o(t.split(",")):Array.isArray(n)?o(n):[n]}var n={install:function(e,n){void 0===n&&(n={});var c=n.lock,f=n.listenTo;void 0===f&&(f="keyup");var l=n.defaultTime;void 0===l&&(l="300ms");var v=n.fireOnEmpty;void 0===v&&(v=!1),e.directive("debounce",{bind:function(n,e){var r=e.value,t=e.arg,i=e.modifiers,o=s(n.attributes,f),u=d(function(e){r(e.value)},t||l);function a(e){var n=e.key,t=e.target,o=!i.lock&&!c||i.unlock;("Enter"===n&&o||!t.value&&v)&&(u.cancel(),r(t.value)),"Enter"!==n&&u(t)}o.forEach(function(e){n.addEventListener(e,a)})}})}};e.debounce=d,e.default=n,Object.defineProperty(e,"__esModule",{value:!0})}); +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).vueDebounce={})}(this,function(e){"use strict";function v(t,e){function n(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];clearTimeout(r),(r=setTimeout(function(){r=null,t.apply(void 0,e)},a))||t.apply(void 0,e)}var o,i,u,r=null,a="number"==typeof e?e:(o=String(e).split(/(ms|s)/i),i=o[0],void 0===(u=o[1])&&(u="ms"),Number(i)*{ms:1,s:1e3}[u]);return n.cancel=function(){clearTimeout(r),r=null},n}function s(e,n){var t=(e.getNamedItem("debounce-events")||{}).value;void 0===t&&(t=!1);function o(e){return e.map(function(e){return e.toLowerCase()})}return t?o(t.split(",")):Array.isArray(n)?o(n):[n]}var n={install:function(e,n){void 0===n&&(n={});var c=n.lock,l=n.listenTo;void 0===l&&(l="keyup");var f=n.defaultTime;void 0===f&&(f="300ms");var d=n.fireOnEmpty;void 0===d&&(d=!1),e.directive("debounce",{bind:function(n,e){var i=e.value,t=e.arg,u=e.modifiers,o=s(n.attributes,l),r=v(function(e){i(e.value)},t||f);function a(e){var n=e.key,t=e.target,o=!u.lock&&!c||u.unlock;("Enter"===n&&o||!t.value&&d)&&(r.cancel(),i(t.value)),"Enter"!==n&&r(t)}o.forEach(function(e){n.addEventListener(e,a)})}})}};e.debounce=v,e.default=n,Object.defineProperty(e,"__esModule",{value:!0})}); From b18c0223adf54b7f4e4d9e4765df00a140603bc1 Mon Sep 17 00:00:00 2001 From: dhershman1 Date: Fri, 21 Feb 2020 15:58:49 -0500 Subject: [PATCH 2/4] tweak tests to new response --- tests/test.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test.html b/tests/test.html index 563254a..6a30dcd 100644 --- a/tests/test.html +++ b/tests/test.html @@ -26,9 +26,10 @@ new Vue({ el: '#app', methods: { - foo (val) { + foo (val, e) { console.log('FOOBAR') console.log(val) + console.log(e) }, testFn(val) { return cbVal => { From 6c53e6c933f869bf5e21c0f6f43f749f02ed79e3 Mon Sep 17 00:00:00 2001 From: dhershman1 Date: Fri, 21 Feb 2020 16:03:27 -0500 Subject: [PATCH 3/4] version bump --- CHANGELOG.md | 6 ++++++ README.md | 5 +++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33cec9b..91eec14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## v2.4.0 + +### New + +- Added the `event` Object itself to the function call, it is passed as the 2nd parameter + ## v2.3.0 ### New diff --git a/README.md b/README.md index 5e362ca..605ee7c 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ You can pass the time in multiple formats: ``` -The value of the input is passed along to your function +The value of the input is passed along to your function as the first parameter, and the 2nd parameter is the event object itself. ## Overwriting Events @@ -146,8 +146,9 @@ A full example: