philomena/assets/js/utils/array.js

12 lines
303 B
JavaScript
Raw Normal View History

2019-10-05 02:09:52 +02:00
// http://stackoverflow.com/a/5306832/1726690
export function moveElement(array, from, to) {
2019-10-05 02:09:52 +02:00
array.splice(to, 0, array.splice(from, 1)[0]);
}
export function arraysEqual(array1, array2) {
2019-10-05 02:09:52 +02:00
for (let i = 0; i < array1.length; ++i) {
if (array1[i] !== array2[i]) return false;
}
return true;
}