Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/local/share/.cache/yarn/v6/npm-debounce-fn-4.0.0-integrity/node_modules/debounce-fn/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict';
const mimicFn = require('mimic-fn');
module.exports = (inputFunction, options = {}) => {
if (typeof inputFunction !== 'function') {
throw new TypeError(`Expected the first argument to be a function, got \`${typeof inputFunction}\``);
}
const {
wait = 0,
before = false,
after = true
} = options;
if (!before && !after) {
throw new Error('Both `before` and `after` are false, function wouldn\'t be called.');
}
let timeout;
let result;
const debouncedFunction = function (...arguments_) {
const context = this;
const later = () => {
timeout = undefined;
if (after) {
result = inputFunction.apply(context, arguments_);
}
};
const shouldCallNow = before && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (shouldCallNow) {
result = inputFunction.apply(context, arguments_);
}
return result;
};
mimicFn(debouncedFunction, inputFunction);
debouncedFunction.cancel = () => {
if (timeout) {
clearTimeout(timeout);
timeout = undefined;
}
};
return debouncedFunction;
};
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.009 ]-- |