UNPKG

@atlaskit/editor-plugin-ncs-step-metrics

Version:

NcsStepMetrics plugin for @atlaskit/editor-core

21 lines (20 loc) 725 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.calculateP90Value = void 0; /** * Calculates the 90th percentile value from an array of step sizes. * @param stepSizeSumFor90 - An array of step sizes to calculate the 90th percentile value. * @returns */ var calculateP90Value = exports.calculateP90Value = function calculateP90Value(stepSizeSumFor90) { if (!stepSizeSumFor90 || (stepSizeSumFor90 === null || stepSizeSumFor90 === void 0 ? void 0 : stepSizeSumFor90.length) === 0) { return 0; } var sortedSteps = stepSizeSumFor90.sort(function (a, b) { return a - b; }); var p90Index = Math.ceil(0.9 * sortedSteps.length) - 1; return sortedSteps[p90Index] || 0; };