mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Switch linter from semistandard to biome
Uses the recommended rules apart from complexity/useArrowFunction, which would affect about 1700 lines of code with little benefit right now. This is something that can be addressed over time.
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
// Copyright 2013 Lovell Fuller and others.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use strict';
|
||||
|
||||
process.env.UV_THREADPOOL_SIZE = 64;
|
||||
|
||||
const assert = require('assert');
|
||||
const assert = require('node:assert');
|
||||
const async = require('async');
|
||||
|
||||
const sharp = require('../../');
|
||||
@@ -21,13 +19,12 @@ const timer = setInterval(function () {
|
||||
}, 100);
|
||||
|
||||
async.mapSeries([1, 1, 2, 4, 8, 16, 32, 64], function (parallelism, next) {
|
||||
const start = new Date().getTime();
|
||||
const start = Date.now();
|
||||
async.times(parallelism,
|
||||
function (id, callback) {
|
||||
/* jslint unused: false */
|
||||
function (_id, callback) {
|
||||
sharp(fixtures.inputJpg).resize(width, height).toBuffer(function (err, buffer) {
|
||||
buffer = null;
|
||||
callback(err, new Date().getTime() - start);
|
||||
callback(err, Date.now() - start);
|
||||
});
|
||||
},
|
||||
function (err, ids) {
|
||||
@@ -37,7 +34,7 @@ async.mapSeries([1, 1, 2, 4, 8, 16, 32, 64], function (parallelism, next) {
|
||||
const mean = ids.reduce(function (a, b) {
|
||||
return a + b;
|
||||
}) / ids.length;
|
||||
console.log(parallelism + ' parallel calls: fastest=' + ids[0] + 'ms slowest=' + ids[ids.length - 1] + 'ms mean=' + mean + 'ms');
|
||||
console.log(`${parallelism} parallel calls: fastest=${ids[0]}ms slowest=${ids[ids.length - 1]}ms mean=${mean}ms`);
|
||||
next();
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
// Copyright 2013 Lovell Fuller and others.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('node:fs');
|
||||
const { execSync } = require('node:child_process');
|
||||
|
||||
const async = require('async');
|
||||
const Benchmark = require('benchmark');
|
||||
@@ -12,7 +10,7 @@ const Benchmark = require('benchmark');
|
||||
const safeRequire = (name) => {
|
||||
try {
|
||||
return require(name);
|
||||
} catch (err) {}
|
||||
} catch (_err) {}
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -280,7 +278,7 @@ async.series({
|
||||
});
|
||||
}
|
||||
}).on('cycle', function (event) {
|
||||
console.log('jpeg ' + String(event.target));
|
||||
console.log(`jpeg ${String(event.target)}`);
|
||||
}).on('complete', function () {
|
||||
callback(null, this.filter('fastest').map('name'));
|
||||
}).run();
|
||||
@@ -505,7 +503,7 @@ async.series({
|
||||
});
|
||||
}
|
||||
}).on('cycle', function (event) {
|
||||
console.log('operations ' + String(event.target));
|
||||
console.log(`operations ${String(event.target)}`);
|
||||
}).on('complete', function () {
|
||||
callback(null, this.filter('fastest').map('name'));
|
||||
}).run();
|
||||
@@ -579,7 +577,7 @@ async.series({
|
||||
});
|
||||
}
|
||||
}).on('cycle', function (event) {
|
||||
console.log('kernels ' + String(event.target));
|
||||
console.log(`kernels ${String(event.target)}`);
|
||||
}).on('complete', function () {
|
||||
callback(null, this.filter('fastest').map('name'));
|
||||
}).run();
|
||||
@@ -735,7 +733,7 @@ async.series({
|
||||
sharp(inputPngBuffer)
|
||||
.resize(width, heightPng)
|
||||
.png({ compressionLevel: 6 })
|
||||
.toBuffer(function (err, data) {
|
||||
.toBuffer(function (err) {
|
||||
if (err) {
|
||||
throw err;
|
||||
} else {
|
||||
@@ -820,7 +818,7 @@ async.series({
|
||||
}
|
||||
});
|
||||
pngSuite.on('cycle', function (event) {
|
||||
console.log(' png ' + String(event.target));
|
||||
console.log(` png ${String(event.target)}`);
|
||||
}).on('complete', function () {
|
||||
callback(null, this.filter('fastest').map('name'));
|
||||
}).run();
|
||||
@@ -881,7 +879,7 @@ async.series({
|
||||
});
|
||||
}
|
||||
}).on('cycle', function (event) {
|
||||
console.log('webp ' + String(event.target));
|
||||
console.log(`webp ${String(event.target)}`);
|
||||
}).on('complete', function () {
|
||||
callback(null, this.filter('fastest').map('name'));
|
||||
}).run();
|
||||
@@ -892,7 +890,7 @@ async.series({
|
||||
}
|
||||
Object.keys(results).forEach(function (format) {
|
||||
if (results[format].toString().substr(0, 5) !== 'sharp') {
|
||||
console.log('sharp was slower than ' + results[format] + ' for ' + format);
|
||||
console.log(`sharp was slower than ${results[format]} for ${format}`);
|
||||
}
|
||||
});
|
||||
console.dir(sharp.cache());
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// Copyright 2013 Lovell Fuller and others.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use strict';
|
||||
|
||||
const imagemagick = require('imagemagick');
|
||||
const gm = require('gm');
|
||||
const assert = require('assert');
|
||||
const assert = require('node:assert');
|
||||
const Benchmark = require('benchmark');
|
||||
|
||||
const sharp = require('../../');
|
||||
@@ -73,5 +71,5 @@ new Benchmark.Suite('random').add('imagemagick', {
|
||||
console.log(String(event.target));
|
||||
}).on('complete', function () {
|
||||
const winner = this.filter('fastest').map('name');
|
||||
assert.strictEqual('sharp', String(winner), 'sharp was slower than ' + winner);
|
||||
assert.strictEqual('sharp', String(winner), `sharp was slower than ${winner}`);
|
||||
}).run();
|
||||
|
||||
Reference in New Issue
Block a user