benchmark: refactor deepequal-buffer

This is a minor refactor of benchmark/assert/deepequal-buffer.js to
reduce exceptions that need to be made for lint compliance.

PR-URL: https://github.com/nodejs/node/pull/21030
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Rich Trott 2018-05-30 03:32:42 +00:00
parent 6168959546
commit 206b19cc3f

View File

@ -14,6 +14,8 @@ const bench = common.createBenchmark(main, {
});
function main({ len, n, method }) {
if (!method)
method = 'deepEqual';
const data = Buffer.allocUnsafe(len + 1);
const actual = Buffer.alloc(len);
const expected = Buffer.alloc(len);
@ -22,8 +24,7 @@ function main({ len, n, method }) {
data.copy(expected);
data.copy(expectedWrong);
// eslint-disable-next-line no-restricted-properties
const fn = method !== '' ? assert[method] : assert.deepEqual;
const fn = assert[method];
const value2 = method.includes('not') ? expectedWrong : expected;
bench.start();