Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ml-array-median

mljs206.7kMIT1.1.6TypeScript support: included

Get the median value in an array

readme

array-median

NPM version npm download

Get the median value in an array, this median use the Floyd-Rivest algorithm.

Thanks to mad-gooze for his median-quickselect lib.

Some benchmarks here.

Installation

$ npm install --save ml-array-median

Usage

import median from 'ml-array-median';

const result = median([1, 5, 3, 2, 4]);
// 3

License

MIT