Array
bounds

Returns a tuple of the min & max values of the given array.

If duplicate values are present in the array, then the first match will be returned.

Related

Syntax

import { bounds } from '@opentf/std';
 
bounds<T>(
  arr: T[] = [],
  by: (val: T) => number = (x: T) => x as number
)

Examples

bounds([1, 2, 3, 4, 5]) //=> [1, 5]
 
const arr = [
  {
    name: 'x',
    age: 10,
  },
  {
    name: 'y',
    age: 16,
  },
  {
    name: 'z',
    age: 13,
  },
  { name: 'y2', age: 16 },
];
bounds(arr, (o) => o.age)
//=> 
// [
//  {
//    name: 'x',
//    age: 10,
//  },
//  {
//    name: 'y',
//    age: 16,
//  },
// ]

Try