Skip to content

Instantly share code, notes, and snippets.

View sethmcleod's full-sized avatar

Seth McLeod sethmcleod

View GitHub Profile

Keybase proof

I hereby claim:

  • I am sethmcleod on github.
  • I am sth (https://keybase.io/sth) on keybase.
  • I have a public key ASCK_WFe5zbkzzdzLhxi3vtRnyIW11UkOB-486-6MQJPfgo

To claim this, I am signing this object:

@sethmcleod
sethmcleod / debounce.js
Last active March 19, 2016 01:38
This limits the rate at which a function can fire, for optimized performance.
function debounce(func, wait, immediate) {
let timeout;
return function() {
const context = this, args = arguments;
const later = function() {
timeout = null;
if (!immediate) {
func.apply(context, args);
}
};
@sethmcleod
sethmcleod / speedTest.js
Last active December 8, 2016 22:51
Javascript constructor for testing function execution speeds
function speedTest(testImplement, testParams, repetitions = 10000) {
// code to be tested
this.testImplement = testImplement;
// parameters needed for code
this.testParams = testParams;
// optional number of reps; higher = better average
this.repetitions = repetitions;
this.average = 0;
}