1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 16:48:08 +02:00

Use Array-destructuring when computing MIN/MAX in AFSimple_Calculate

This appears to work fine with QuickJS, as evident by the added unit-test, and allows us to remove more `Array.prototype.reduce` usage.
This commit is contained in:
Jonas Jenwald 2025-04-06 11:44:08 +02:00
parent 6cc37c8415
commit 0845552ff9
2 changed files with 112 additions and 4 deletions

View file

@ -392,10 +392,8 @@ class AForm {
AVG: args => args.reduce((acc, value) => acc + value, 0) / args.length,
SUM: args => args.reduce((acc, value) => acc + value, 0),
PRD: args => args.reduce((acc, value) => acc * value, 1),
MIN: args =>
args.reduce((acc, value) => Math.min(acc, value), Number.MAX_VALUE),
MAX: args =>
args.reduce((acc, value) => Math.max(acc, value), Number.MIN_VALUE),
MIN: args => Math.min(...args),
MAX: args => Math.max(...args),
};
if (!(cFunction in actions)) {