This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from 'react' | |
type PerformanceEntryEnhanced = PerformanceEntry & { | |
interactionId?: string | |
} | |
let worstInp = 0 | |
const useINPMonitor = () => { | |
if ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Loop over array over and over according to its length | |
*/ | |
let array1 = ['a', 'b', 'c', 'd'] | |
let array2 = [...Array(100)].map((i,o) => o) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function canExecutePreventDefault () { | |
let supportsPassive = false; | |
try { | |
document.addEventListener("test", null, { get passive() { supportsPassive = true }}); | |
} catch(e) {} | |
return supportsPassive | |
} | |
// https://github.com/Modernizr/Modernizr/blob/a747f33b2bc5db186f18bca4d1d63bf503d3159d/feature-detects/dom/passiveeventlisteners.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nextInSequence = (last, initLength = 5) => { | |
let seq = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] | |
last = last.split('').reverse() | |
let arrShift = arr => { | |
if(seq.indexOf(arr[0]) >= seq.length - 1) { | |
arr.shift() | |
} | |
if(seq.indexOf(arr[0]) < seq.length - 1){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var IMAGE_MIME_REGEX = /^image\/(p?jpeg|gif|png)$/i; | |
var loadImage = function (file) { | |
var reader = new FileReader(); | |
reader.onload = function(e){ | |
var img = document.createElement('img'); | |
img.src = e.target.result; | |
var range = window.getSelection().getRangeAt(0); | |
range.deleteContents(); |