So I was curious how mocha implements their: "be synchronous if callback is undefined, be async if callback is defined". The way to do this is by using Function.length
// fn, fn -> null
function detect (fn, cb) {
if (fn.length) return fn(() => cb())
fn() && cb()
}