🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

minimaximator

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minimaximator

A Node.js package that allows you to get the lowest and the highest number of an array with one function call

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

minMax method

A Node.js package that allows you to get the lowest and the highest number of an array with one function call.

Twitter

Travis npm Coverage Status

Sponsor

Sponsor

Example

Currently, if you have an array of numbers and you want to get the lowest and the highest number you have to:

const nums = [12, 10, 25, 5]
const min = Math.min(nums)
const max = Math.max(nums)
console.log(min, max) // 5 25

...but with this lib, you are able to do:

const { minMax } = require('minimaximator')
const nums = [12, 10, 25, 5]
const [min, max] = minMax(nums)
console.log(min, max) // 5 25

Benchmark

There is benchmark in the benchmark folder that you can run. Here is a typical example with 100 numbers:

Two calls x 146,444 ops/sec ±1.67% (86 runs sampled)
Minmax function x 5,693,000 ops/sec ±0.64% (90 runs sampled)
Fastest is Minmax function

And here is a typical example with 100000 numbers:

Two calls x 25.93 ops/sec ±7.60% (40 runs sampled)
Minmax function x 9,315 ops/sec ±0.44% (89 runs sampled)
Fastest is Minmax function

FAQs

Package last updated on 27 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts