Add new version in repository

This commit is contained in:
Ludovic CANDELLIER
2021-07-25 23:19:27 +02:00
parent f75632b054
commit b879f11c99
608 changed files with 12235 additions and 7513 deletions

View File

@@ -0,0 +1,21 @@
// Array Helpers
const countOccurrences = arr => arr.reduce((prev, curr) => (prev[curr] = ++prev[curr] || 1, prev), {});
const isEmpty = arr => !(Array.isArray(arr) && arr.length > 0 && arr.filter(el => el === undefined).length > 0)
const isEqual = (a, b) => JSON.stringify(a.sort()) === JSON.stringify(b.sort());
const countBy = (arr, prop) => arr.reduce((prev, curr) => (prev[curr[prop]] = ++prev[curr[prop]] || 1, prev), {});
const transpose = matrix => matrix[0].map((col, i) => matrix.map(row => row[i]));
// Dom Helpers
const insertAfter = (ele, anotherEle) => anotherEle.parentNode.insertBefore(ele, anotherEle.nextSibling);
const insertBefore = (ele, anotherEle) => anotherEle.parentNode.insertBefore(ele, anotherEle);
const insertHtmlAfter = (html, ele) => ele.insertAdjacentHTML('afterend', html);
const insertHtmlBefore = (html, ele) => ele.insertAdjacentHTML('beforebegin', html);
const goTo = url => location.href = url;
const replace = (ele, newEle) => ele.parentNode.replaceChild(newEle, ele);
const toNumbers = arr => arr.map(Number);
const wait = async (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
const capitalize = str => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
const slugify = string => string.toLowerCase().replace(/\s+/g, '-').replace(/[^\w-]+/g, '');
const isNumeric = str => !/[^0-9]/.test(str);