Skip to content

Instantly share code, notes, and snippets.

View electerious's full-sized avatar

Tobias Reich electerious

View GitHub Profile
{
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"react"
const throttle = (fn, threshold) => {
let last
let timeout
return (...args) => {
const now = Date.now()
const shouldDelay = last && now < last + threshold
const delay = shouldDelay === true ? threshold - (now - last) : 0
@electerious
electerious / debounce.js
Last active December 12, 2018 08:18 — forked from jasonwyatt/debouncer.js
How to **correctly** debounce an event that will be triggered many times with identical arguments.
const debounce = function(fn, duration) {
let timeout = null
return (...args) => {
clearTimeout(timeout)
timeout = setTimeout(() => fn(...args), duration)
<label for="familyname">Family name</label>
<input id="familyname" name="familyname" type="text" autocorrect="off" autocomplete="family-name" placeholder="Berners-Lee">
<select disabled>
<option value="a">A</option>
<option value="b">B</option>
</select>
<select>
<option disabled>Choose A or B</option>
<option value="a">A</option>
<option value="b">B</option>
</select>
<input placeholder="Jane Doe" ...>
<label for="email">E-Mail</label>
<input id="email" ...>
<input pattern="\d*" ...>
<input type="email" ...>
<input type="url" ...>
<input required ...>
<input autocomplete="tel" ...>
<input autocomplete="email" ...>