Skip to content

Commit

Permalink
Replace batch with async package
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkemp committed Dec 27, 2024
1 parent 3ae35d1 commit 951529a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
7 changes: 7 additions & 0 deletions packages/extract-css/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# extract-css

## 3.0.2

### Patch Changes

- Replace batch with async package
11 changes: 6 additions & 5 deletions packages/extract-css/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
const assert = require('assert');
const Batch = require('batch');
const async = require('async');
const getStylesData = require('style-data');
const getStylesheetList = require('list-stylesheets');
const getHrefContent = require('href-content');

module.exports = (html, options, callback) => {
const batch = new Batch();
const tasks = [];
const data = getStylesheetList(html, options);

batch.push(cb => {
tasks.push(cb => {
getStylesData(data.html, options, cb);
});
if (data.hrefs.length) {
assert.ok(options.url, 'options.url is required');
}
data.hrefs.forEach(stylesheetHref => {
batch.push(cb => {
tasks.push(cb => {
getHrefContent(stylesheetHref, options.url, cb);
});
});
batch.end((err, results) => {

async.parallel(tasks, (err, results) => {
let stylesData;
let css;

Expand Down
6 changes: 3 additions & 3 deletions packages/extract-css/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "extract-css",
"version": "3.0.1",
"version": "3.0.2",
"description": "Extract the CSS from an HTML document.",
"main": "index.js",
"files": [
Expand All @@ -14,8 +14,8 @@
"license": "MIT",
"homepage": "https://github.com/jonkemp/inline-css/tree/master/packages/extract-css",
"dependencies": {
"batch": "^0.6.1",
"href-content": "^2.0.2",
"async": "^3.2.6",
"href-content": "^2.0.3",
"list-stylesheets": "^2.0.1",
"style-data": "^2.0.1"
}
Expand Down

0 comments on commit 951529a

Please sign in to comment.