MCPcopy Create free account
hub / github.com/chart-kit/react-native-chart-kit-example / getPercentile

Function getPercentile

benchmarks/chart-scrub.spec.ts:75–87  ·  view source on GitHub ↗
(values: number[], percentage: number)

Source from the content-addressed store, hash-verified

73 };
74 const samples = globalWindow.__chartKitScrubFrameSamples ?? [];
75 const getPercentile = (values: number[], percentage: number) => {
76 if (values.length === 0) {
77 return Number.NaN;
78 }
79
80 const sorted = [...values].sort((a, b) => a - b);
81 const index = Math.min(
82 sorted.length - 1,
83 Math.floor((percentage / 100) * sorted.length)
84 );
85
86 return sorted[index] ?? Number.NaN;
87 };
88
89 globalWindow.__stopChartKitScrubBenchmark?.();
90

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected