Define arbitrary ways to limit a JavaScript function