@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
8 lines • 355 B
JavaScript
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
export function median(array) {
var middle = Math.floor(array.length / 2);
var sortedArray = _toConsumableArray(array).sort(function (a, b) {
return a - b;
});
return array.length % 2 !== 0 ? sortedArray[middle] : (sortedArray[middle - 1] + sortedArray[middle]) / 2;
}