Socket
Socket
Sign inDemoInstall

@mapbox/appropriate-images

Package Overview
Dependencies
296
Maintainers
14
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.1.0-beta.4 to 4.1.0-beta.5

50

lib/optimize.js

@@ -18,3 +18,3 @@ 'use strict';

*/
function writeOptimizedImages(imageData) {
async function writeOptimizedImages(imageData) {
return Promise.all(

@@ -41,24 +41,36 @@ imageData.map((item) =>

*/
module.exports = (imageFilenames, options) => {
module.exports = async (imageFilenames, options) => {
// These are two separate processes because otherwise the webp plugin
// overrides the others, somehow.
let filenameArrays = [];
try {
const regularOptimizations = await imagemin(imageFilenames, {
destination: options.outputDirectory,
plugins: [
imageminPngquant(options.pngquant),
imageminMozjpeg(options.mozjpeg)
]
});
filenameArrays = [
...filenameArrays,
...(await writeOptimizedImages(regularOptimizations))
];
} catch (err) {
throw new Error(err);
}
const regularOptimizations = imagemin(imageFilenames, {
destination: options.outputDirectory,
plugins: [
imageminPngquant(options.pngquant),
imageminMozjpeg(options.mozjpeg)
]
})
.then(writeOptimizedImages)
.catch((err) => console.log(err));
try {
const webpOptimizations = await imagemin(imageFilenames, {
destination: options.outputDirectory,
plugins: [imageminWebp(options.webp)]
});
filenameArrays = [
...filenameArrays,
...(await writeOptimizedImages(webpOptimizations))
];
} catch (err) {
throw new Error(err);
}
const webpOptimizations = imagemin(imageFilenames, {
destination: options.outputDirectory,
plugins: [imageminWebp(options.webp)]
}).then(writeOptimizedImages);
return Promise.all([regularOptimizations, webpOptimizations])
.then((filenameArrays) => _.flatten(filenameArrays))
.catch((err) => console.log(err));
return _.flatten(filenameArrays);
};
{
"name": "@mapbox/appropriate-images",
"version": "4.1.0-beta.4",
"version": "4.1.0-beta.5",
"description": "Get appropriately sized images into your website.",

@@ -31,3 +31,3 @@ "main": "index.js",

"engines": {
"node": ">=10"
"node": ">=12"
},

@@ -34,0 +34,0 @@ "dependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc