1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-11-22 03:13:33 +01:00

Use es6 destructuring swap for shuffling

This commit is contained in:
nimbleghost 2023-05-24 17:49:04 +02:00
parent 9056d68fc9
commit 4d90e32fe9

View file

@ -139,17 +139,14 @@ export const maybeAppendActionErrors = (message, notification) => {
};
export const shuffle = (arr) => {
let j;
let x;
for (let index = arr.length - 1; index > 0; index -= 1) {
j = Math.floor(Math.random() * (index + 1));
x = arr[index];
// eslint-disable-next-line no-param-reassign
arr[index] = arr[j];
// eslint-disable-next-line no-param-reassign
arr[j] = x;
const returnArr = [...arr];
for (let index = returnArr.length - 1; index > 0; index -= 1) {
const j = Math.floor(Math.random() * (index + 1));
[returnArr[index], returnArr[j]] = [returnArr[j], returnArr[index]];
}
return arr;
return returnArr;
};
export const splitNoEmpty = (s, delimiter) =>