utilityまとめ.js
const $$ = document;
const $ = v => v.startsWith('#') ? $$.getElementById(v.slice(1)) : $$.querySelector(v);
const _$ = (e = "div") => $$.createElement(e);
const DOM = str => new DOMParser().parseFromString(str, "text/html").body.firstElementChild;
const attr = (e, att) => Object.entries(att).map(([k, v]) => e[k] = v);
const css = (e, sty) => Object.entries(sty).map(([k, v]) => e.style[k] = v);
const event = (e, f, v = 'click') => e.addEventListener(v, f);
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
const now = new Date().toISOString().split("T")[0].replaceAll("-", "");
タイマー付き遅延関数.js
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
const delay = async function(f, m) {
for (i = 1; i <= m; ++i) {
await sleep(6e4);
console.log(`\u001b[36m${i}分\u001b[0m経過`);
}
console.log('=== \u001b[31m実行\u001b[0m ===');
f();
};
delay(() => {
// 処理を書く
}, 5); // 5分後に実行