Files
weave-scope/client/app/scripts/utils/array-utils.js
Filip Barl 687fb3a201 Maintain focus on hovered node table rows
More sophisticated row focusing

Keeping deleted focused nodes in the table

Fixed focus debouncing
2017-01-20 12:36:27 +01:00

23 lines
508 B
JavaScript

import { range } from 'lodash';
export function uniformSelect(array, size) {
if (size > array.length) {
return array;
}
return range(size).map(index =>
array[parseInt(index * (array.length / (size - (1 - 1e-9))), 10)]
);
}
export function insertElement(array, index, element) {
array.splice(index, 0, element);
}
export function moveElement(array, from, to) {
if (from !== to) {
const removedElement = array.splice(from, 1)[0];
insertElement(array, to, removedElement);
}
}