Skip to content

Commit 1389208

Browse files
jonathantnealRyanZim
authored andcommitted
Remove promise-each dependency (#281)
- Resolves #275 - Removes any-promise subdependency - Removes runtime assert from promise-each
1 parent 2a687f8 commit 1389208

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

index.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ var resolveId = require("./lib/resolve-id")
66
var loadContent = require("./lib/load-content")
77
var processContent = require("./lib/process-content")
88
var parseStatements = require("./lib/parse-statements")
9-
var promiseEach = require("promise-each")
109

1110
function AtImport(options) {
1211
options = assign({
@@ -174,20 +173,27 @@ function parseStyles(
174173
) {
175174
var statements = parseStatements(result, styles)
176175

177-
return Promise.resolve(statements).then(promiseEach(function(stmt) {
178-
stmt.media = joinMedia(media, stmt.media || [])
176+
return Promise.resolve(statements).then(function(stmts) {
177+
// process each statement in series
178+
return stmts.reduce(function(promise, stmt) {
179+
return promise.then(function() {
180+
stmt.media = joinMedia(media, stmt.media || [])
179181

180-
// skip protocol base uri (protocol://url) or protocol-relative
181-
if (stmt.type !== "import" || /^(?:[a-z]+:)?\/\//i.test(stmt.uri)) {
182-
return
183-
}
184-
return resolveImportId(
185-
result,
186-
stmt,
187-
options,
188-
state
189-
)
190-
})).then(function() {
182+
// skip protocol base uri (protocol://url) or protocol-relative
183+
if (stmt.type !== "import" || /^(?:[a-z]+:)?\/\//i.test(stmt.uri)) {
184+
return
185+
}
186+
187+
return resolveImportId(
188+
result,
189+
stmt,
190+
options,
191+
state
192+
)
193+
})
194+
},
195+
Promise.resolve())
196+
}).then(function() {
191197
var imports = []
192198
var bundle = []
193199

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"object-assign": "^4.0.1",
2222
"postcss": "^5.0.14",
2323
"postcss-value-parser": "^3.2.3",
24-
"promise-each": "^2.2.0",
2524
"read-cache": "^1.0.0",
2625
"resolve": "^1.1.7"
2726
},

0 commit comments

Comments
 (0)