added regex escaping function

This commit is contained in:
Miodec 2022-03-03 19:06:06 +01:00
parent 6748f30b15
commit 70d0639fc7

View file

@ -2,6 +2,10 @@ export function roundTo2(num) {
return Math.round((num + Number.EPSILON) * 100) / 100;
}
export function escapeRegExp(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
export function stdDev(array) {
const n = array.length;
const mean = array.reduce((a, b) => a + b) / n;