{"size": 417, "ext": "js", "max_stars_repo_path": "js/fn - debounce().js", "max_stars_repo_name": "m-ahmadi/exref", "max_stars_repo_stars_event_min_datetime": "2019-08-28T16:06:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-31T10:36:08.000Z", "max_issues_repo_path": "js/fn - debounce().js", "max_issues_repo_name": "m-ahmadi/exref", "max_issues_repo_issues_event_min_datetime": "2022-02-23T05:50:57.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-25T16:56:02.000Z", "max_forks_repo_path": "js/fn - debounce().js", "max_forks_repo_name": "m-ahmadi/exref", "max_forks_repo_forks_event_min_datetime": "2019-08-28T16:06:23.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-19T20:24:41.000Z"}
{"max_stars_count": 9, "max_issues_count": 1, "max_forks_count": 5, "avg_line_length": 26.0625, "max_line_length": 68, "alphanum_fraction": 0.6522781775}
function debounce(fn, wait) {
	let timeout
	return function (...args) {
		clearTimeout(timeout);
		timeout = setTimeout(() => fn.apply(this, args), wait);
	};
}

var foo = debounce(i => console.log(i), 0);

[...Array(1000)].forEach((v,i)=> foo(i) ) // only prints 999

// you can't return a value from debounced functions (use callbacks)
function foo(a,b) { return a+b }
_foo = debounce(foo, 0)
_foo(2,2) // undefined