mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-22 03:35:53 +10:00
20 lines
395 B
JavaScript
20 lines
395 B
JavaScript
module.exports = function tryChain (resolvers, arg) {
|
|
let response
|
|
let error
|
|
for (let resolver of resolvers) {
|
|
if (!Array.isArray(resolver)) {
|
|
resolver = [resolver, true]
|
|
}
|
|
const [provider, condition] = resolver
|
|
if (!condition) {
|
|
continue
|
|
}
|
|
try {
|
|
response = provider(arg, error)
|
|
return response
|
|
} catch (e) {
|
|
error = e
|
|
}
|
|
}
|
|
}
|