-
Notifications
You must be signed in to change notification settings - Fork 3
rangeEntries
Subhajit Sahu edited this page Dec 8, 2022
·
1 revision
Find smallest and largest entries.
Similar: range, rangeEntries.
Similar: min, max, range
function rangeEntries(x, fc, fm)
// x: an object
// fc: compare function (a, b)
// fm: map function (v, k, x)
const object = require('extra-object');
var x = {a: 1, b: 2, c: -3, d: -4};
object.rangeEntries(x);
// → [ [ 'd', -4 ], [ 'b', 2 ] ]
object.rangeEntries(x, (a, b) => Math.abs(a) - Math.abs(b));
// → [ [ 'a', 1 ], [ 'd', -4 ] ]
object.rangeEntries(x, null, v => Math.abs(v));
// → [ [ 'a', 1 ], [ 'd', -4 ] ]