Skip to content

Commit 697e5e3

Browse files
authored
Use reduce() method to get the total size of Uint8Arrays (#39374)
1 parent 37710b2 commit 697e5e3

File tree

1 file changed

+1
-4
lines changed
  • files/en-us/mozilla/add-ons/webextensions/api/webrequest/streamfilter/ondata

1 file changed

+1
-4
lines changed

files/en-us/mozilla/add-ons/webextensions/api/webrequest/streamfilter/ondata/index.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,7 @@ function listener(details) {
229229
};
230230

231231
filter.onstop = (event) => {
232-
let combinedLength = 0;
233-
for (const buffer of data) {
234-
combinedLength += buffer.length;
235-
}
232+
const combinedLength = data.reduce((acc, buffer) => acc + buffer.length, 0);
236233
const combinedArray = new Uint8Array(combinedLength);
237234
let writeOffset = 0;
238235
for (const buffer of data) {

0 commit comments

Comments
 (0)