es-toolkit
Advanced tools
Comparing version 1.4.0-dev.88 to 1.4.0-dev.89
@@ -41,2 +41,3 @@ export { chunk } from './array/chunk.js'; | ||
export { sum } from './math/sum.js'; | ||
export { maxBy } from './math/maxBy.js'; | ||
export { omit } from './object/omit.js'; | ||
@@ -43,0 +44,0 @@ export { omitBy } from './object/omitBy.js'; |
@@ -57,2 +57,3 @@ "use strict"; | ||
isUndefined: () => isUndefined, | ||
maxBy: () => maxBy, | ||
noop: () => noop, | ||
@@ -456,2 +457,16 @@ omit: () => omit, | ||
// src/math/maxBy.ts | ||
function maxBy(elements, selector) { | ||
let maxElement = elements[0]; | ||
let max = -Infinity; | ||
for (const element of elements) { | ||
const value = selector(element); | ||
if (value > max) { | ||
max = value; | ||
maxElement = element; | ||
} | ||
} | ||
return maxElement; | ||
} | ||
// src/object/omit.ts | ||
@@ -558,2 +573,3 @@ function omit(obj, keys) { | ||
isUndefined, | ||
maxBy, | ||
noop, | ||
@@ -560,0 +576,0 @@ omit, |
@@ -6,1 +6,2 @@ export { clamp } from './clamp.js'; | ||
export { sum } from './sum.js'; | ||
export { maxBy } from './maxBy.js'; |
@@ -24,2 +24,3 @@ "use strict"; | ||
clamp: () => clamp, | ||
maxBy: () => maxBy, | ||
random: () => random, | ||
@@ -67,5 +68,20 @@ randomInt: () => randomInt, | ||
} | ||
// src/math/maxBy.ts | ||
function maxBy(elements, selector) { | ||
let maxElement = elements[0]; | ||
let max = -Infinity; | ||
for (const element of elements) { | ||
const value = selector(element); | ||
if (value > max) { | ||
max = value; | ||
maxElement = element; | ||
} | ||
} | ||
return maxElement; | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
clamp, | ||
maxBy, | ||
random, | ||
@@ -72,0 +88,0 @@ randomInt, |
{ | ||
"name": "es-toolkit", | ||
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.", | ||
"version": "1.4.0-dev.88+3ecc0626", | ||
"version": "1.4.0-dev.89+260bae96", | ||
"workspaces": [ | ||
@@ -6,0 +6,0 @@ "docs" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
531631
474
5718