If you hear SOI SOI SOI, you better RUN RUN RUN ’cause the ROFLCOPTER ASCII army is coming for you!
ROFL:ROFL:ROFL:ROFL
_^___
L __/ [] \
| import { decode } from "blurhash" | |
| export function blurHashToDataURL(hash: string | undefined): string | undefined { | |
| if (!hash) return undefined | |
| const pixels = decode(hash, 32, 32) | |
| const dataURL = parsePixels(pixels, 32, 32) | |
| return dataURL | |
| } |
| class BetterMap<k, v> extends Map<k, v> { | |
| update(key:k, updater: (v:v, k:k) => v, notset:v = undefined) { | |
| if(this.has(key)) this.set(key, updater(this.get(key), key)) | |
| else this.set(key, notset) | |
| } | |
| filter(predicate: (v:v, k:k) => boolean) { | |
| const newMap = new BetterMap<k, v>() | |
| const entries = Array.from(this.entries()) | |
| for(const [key, value] of entries) { |
if(document.queryCommandSupported('copy')) {
if(text=='') { text = ' '; } // empty inputs do not get selected
// copy text to off-screen input
$('#clipboard').val(text);
// 1.) does copy empty inputs, but adds newline before content
var range = document.createRange();
range.selectNode(document.querySelector('#clipboard'));