postcss-image-inliner
Advanced tools
Comparing version 7.0.0 to 7.0.1
@@ -30,10 +30,2 @@ 'use strict'; | ||
async function reduceAsync(array = [], reducer = (r) => r, initial) { | ||
for (const index of array.keys()) { | ||
initial = await reducer(initial, array[index]); /* eslint-disable-line no-await-in-loop */ | ||
} | ||
return initial; | ||
} | ||
async function assertSize(resource, maxFileSize, throwError = true) { | ||
@@ -81,22 +73,23 @@ const {mime, contents = ''} = resource || {}; | ||
function getDataUriMapping(urls = [], options = {}) { | ||
return reduceAsync( | ||
[...new Set(urls)], | ||
async (result, url) => { | ||
const file = await resolve(url, options); | ||
if (file && file.mime && /image/.test(file.mime)) { | ||
result[url] = await getDataUri(file, options); | ||
} else if (options.largeFileCallback) { | ||
const largeFile = await resolve(url, {...options, maxFileSize: 0}); | ||
if (largeFile && largeFile.mime && /image/.test(largeFile.mime)) { | ||
result[url] = await options.largeFileCallback(largeFile); | ||
} | ||
async function getDataUriMapping(urls = [], options = {}) { | ||
const uniqueUrls = [...new Set(urls)]; | ||
const promises = uniqueUrls.map(async (url) => { | ||
const file = await resolve(url, options); | ||
if (file && file.mime && /image/.test(file.mime)) { | ||
return [url, await getDataUri(file, options)]; | ||
} | ||
if (options.largeFileCallback) { | ||
const largeFile = await resolve(url, {...options, maxFileSize: 0}); | ||
if (largeFile && largeFile.mime && /image/.test(largeFile.mime)) { | ||
return [url, await options.largeFileCallback(largeFile)]; | ||
} | ||
} | ||
return result; | ||
}, | ||
{} | ||
); | ||
return [url, null]; | ||
}); | ||
const results = await Promise.all(promises); | ||
return Object.fromEntries(results); | ||
} | ||
module.exports.getDataUriMapping = getDataUriMapping; |
{ | ||
"name": "postcss-image-inliner", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"description": "PostCSS plugin to inline images into css", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -97,1 +97,9 @@ # PostCSS Image Inliner [![Build Status][ci-img]][ci] | ||
Fail on error. | ||
#### filter | ||
* Type: `regex` | ||
* Default: `/^(background(?:-image)?)|(content)|(cursor)/` | ||
* Required: `false` | ||
Regex to match the CSS properties to be inlined. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10060
105
146