-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 18 and modern browsers
- Loading branch information
1 parent
2b78c0d
commit 2872fb8
Showing
16 changed files
with
330 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
components | ||
build | ||
node_modules | ||
node_modules | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,11 @@ | ||
MIT License | ||
|
||
Copyright (c) 2012-2018 The Debounce Contributors. See CONTRIBUTORS. | ||
Coprighht (c) Jeremy Ashkenas, Julian Gonggrijp, DocumentCloud, Investigative Reporters & Editors | ||
Copyright (c) Ben Carpenter, Billy Moon, Josh Goldberg, Julian Gruber, Kristofer Selbekk, Matthew Mueller, Nathan Rajlich, Oleg Pudeyev, Stephen Mathieson, TJ Holowaychuk, suhaotian, ven | ||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
type AnyFunction = (...arguments_: readonly any[]) => unknown; | ||
|
||
/** | ||
Returns a function, that, as long as it continues to be invoked, will not be triggered. The function will be called after it stops being called for N milliseconds. | ||
If `immediate` is passed, trigger the function on the leading edge, instead of the trailing. The function also has a property 'clear' that is a function which will clear the timer to prevent previously scheduled executions. | ||
*/ | ||
declare function debounce<F extends AnyFunction>( | ||
function_: F, | ||
wait?: number, | ||
immediate?: boolean | ||
): debounce.DebouncedFunction<F>; | ||
|
||
declare namespace debounce { | ||
type DebouncedFunction<F extends AnyFunction> = { | ||
(...arguments_: Parameters<F>): ReturnType<F> | undefined; | ||
clear(): void; | ||
flush(): void; | ||
}; | ||
} | ||
|
||
export = debounce; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,78 @@ | ||
/** | ||
* Returns a function, that, as long as it continues to be invoked, will not | ||
* be triggered. The function will be called after it stops being called for | ||
* N milliseconds. If `immediate` is passed, trigger the function on the | ||
* leading edge, instead of the trailing. The function also has a property 'clear' | ||
* that is a function which will clear the timer to prevent previously scheduled executions. | ||
* | ||
* @source underscore.js | ||
* @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/ | ||
* @param {Function} func function to wrap | ||
* @param {number} [wait=100] time to wait in ms (`100`) | ||
* @param {boolean} [immediate=false] should execute at the beginning (`false`) | ||
* @api public | ||
*/ | ||
function debounce(func, wait, immediate){ | ||
var timeout, args, context, timestamp, result; | ||
if (null == wait) wait = 100; | ||
|
||
function later() { | ||
var last = Date.now() - timestamp; | ||
|
||
if (last < wait && last >= 0) { | ||
timeout = setTimeout(later, wait - last); | ||
} else { | ||
timeout = null; | ||
if (!immediate) { | ||
var callContext = context, callArgs = args | ||
context = args = null; | ||
result = func.apply(callContext, callArgs); | ||
} | ||
} | ||
}; | ||
|
||
var debounced = function(){ | ||
context = this; | ||
args = arguments; | ||
timestamp = Date.now(); | ||
var callNow = immediate && !timeout; | ||
if (!timeout) timeout = setTimeout(later, wait); | ||
if (callNow) { | ||
var callContext = context, callArgs = args | ||
context = args = null; | ||
result = func.apply(callContext, callArgs); | ||
} | ||
|
||
return result; | ||
}; | ||
|
||
debounced.clear = function() { | ||
if (timeout) { | ||
clearTimeout(timeout); | ||
timeout = null; | ||
} | ||
}; | ||
|
||
debounced.flush = function() { | ||
if (timeout) { | ||
var callContext = context, callArgs = args; | ||
context = args = null; | ||
result = func.apply(callContext, callArgs); | ||
|
||
clearTimeout(timeout); | ||
timeout = null; | ||
} | ||
}; | ||
|
||
return debounced; | ||
}; | ||
function debounce(function_, wait = 100, immediate) { | ||
let storedContext; | ||
let storedArguments; | ||
let timeoutId; | ||
let timestamp; | ||
let result; | ||
|
||
function later() { | ||
const last = Date.now() - timestamp; | ||
|
||
if (last < wait && last >= 0) { | ||
timeoutId = setTimeout(later, wait - last); | ||
} else { | ||
timeoutId = undefined; | ||
|
||
if (!immediate) { | ||
const callContext = storedContext; | ||
const callArguments = storedArguments; | ||
storedContext = undefined; | ||
storedArguments = undefined; | ||
result = function_.apply(callContext, callArguments); | ||
} | ||
} | ||
} | ||
|
||
const debounced = function (...arguments_) { | ||
storedContext = this; // eslint-disable-line unicorn/no-this-assignment | ||
storedArguments = arguments_; | ||
timestamp = Date.now(); | ||
|
||
const callNow = immediate && !timeoutId; | ||
|
||
if (!timeoutId) { | ||
timeoutId = setTimeout(later, wait); | ||
} | ||
|
||
if (callNow) { | ||
const callContext = storedContext; | ||
const callArguments = storedArguments; | ||
storedContext = undefined; | ||
storedArguments = undefined; | ||
result = function_.apply(callContext, callArguments); | ||
} | ||
|
||
return result; | ||
}; | ||
|
||
debounced.clear = () => { | ||
if (!timeoutId) { | ||
return; | ||
} | ||
|
||
clearTimeout(timeoutId); | ||
timeoutId = undefined; | ||
}; | ||
|
||
debounced.flush = () => { | ||
if (!timeoutId) { | ||
return; | ||
} | ||
|
||
const callContext = storedContext; | ||
const callArguments = storedArguments; | ||
storedContext = undefined; | ||
storedArguments = undefined; | ||
result = function_.apply(callContext, callArguments); | ||
|
||
clearTimeout(timeoutId); | ||
timeoutId = undefined; | ||
}; | ||
|
||
return debounced; | ||
} | ||
|
||
// Adds compatibility for ES modules | ||
debounce.debounce = debounce; | ||
module.exports.debounce = debounce; | ||
|
||
module.exports = debounce; |
Oops, something went wrong.