合并utils

dev/code-splitting
Lei OT 2 years ago
parent 18b699165c
commit 303e7db925

@ -52,16 +52,16 @@ export function prepareUrl(url) {
return new UrlBuilder(url)
}
export function debounce(fn, delay = 500) {
let timer
return e => {
e.persist()
clearTimeout(timer)
timer = setTimeout(() => {
fn(e)
}, delay)
}
}
// export function debounce(fn, delay = 500) {
// let timer
// return e => {
// e.persist()
// clearTimeout(timer)
// timer = setTimeout(() => {
// fn(e)
// }, delay)
// }
// }
export function throttle(fn, delay, atleast) {
let timeout = null,
@ -409,19 +409,19 @@ export const stringToColour = (str) => {
return colour
}
// export const debounce = (func, wait, immediate) => {
// var timeout;
// return function () {
// var context = this,
// args = arguments;
// clearTimeout(timeout);
// if (immediate && !timeout) func.apply(context, args);
// timeout = setTimeout(function () {
// timeout = null;
// if (!immediate) func.apply(context, args);
// }, wait);
// };
// }
export const debounce = (func, wait, immediate) => {
var timeout;
return function () {
var context = this,
args = arguments;
clearTimeout(timeout);
if (immediate && !timeout) func.apply(context, args);
timeout = setTimeout(function () {
timeout = null;
if (!immediate) func.apply(context, args);
}, wait);
};
}
export const olog = (text, ...args) => {
console.log(

Loading…
Cancel
Save