Skip to content

Commit

Permalink
test: reduce scope of variable in common module
Browse files Browse the repository at this point in the history
arrayBufferViews is used by only one function so scope it to that
function (in the common module).

PR-URL: #17830
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
Trott authored and MylesBorins committed Jan 9, 2018
1 parent 1be0086 commit 8b666d6
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -788,23 +788,24 @@ exports.skipIf32Bits = function skipIf32Bits() {
}
};

const arrayBufferViews = [
Int8Array,
Uint8Array,
Uint8ClampedArray,
Int16Array,
Uint16Array,
Int32Array,
Uint32Array,
Float32Array,
Float64Array,
DataView
];

exports.getArrayBufferViews = function getArrayBufferViews(buf) {
const { buffer, byteOffset, byteLength } = buf;

const out = [];

const arrayBufferViews = [
Int8Array,
Uint8Array,
Uint8ClampedArray,
Int16Array,
Uint16Array,
Int32Array,
Uint32Array,
Float32Array,
Float64Array,
DataView
];

for (const type of arrayBufferViews) {
const { BYTES_PER_ELEMENT = 1 } = type;
if (byteLength % BYTES_PER_ELEMENT === 0) {
Expand Down

0 comments on commit 8b666d6

Please sign in to comment.