Рекурсивное получение массива значений в хэше/дереве
import flatMapDeep from 'lodash/flatMapDeep'
function getResponseErrors(errors) {
function deep(n) {
if (typeof(n) === 'object') return flatMapDeep(n, deep);
return n;
}
return flatMapDeep(errors, deep);
}
Get element by XPath
function getElementByXpath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
Random value on range
Math.floor(Math.random() * (max - min) + min)