mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
More sophisticated row focusing Keeping deleted focused nodes in the table Fixed focus debouncing
23 lines
508 B
JavaScript
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);
|
|
}
|
|
}
|