2019-12-20 10:53:27 -05:00
|
|
|
function createPlugin(plugin, config) {
|
|
|
|
|
return {
|
|
|
|
|
handler: plugin,
|
|
|
|
|
config,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-16 13:30:06 -04:00
|
|
|
createPlugin.withOptions = function (pluginFunction, configFunction = () => ({})) {
|
|
|
|
|
const optionsFunction = function (options) {
|
2019-12-20 10:53:27 -05:00
|
|
|
return {
|
|
|
|
|
handler: pluginFunction(options),
|
2020-01-04 12:35:12 -05:00
|
|
|
config: configFunction(options),
|
2019-12-20 10:53:27 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
optionsFunction.__isOptionsFunction = true
|
|
|
|
|
|
|
|
|
|
return optionsFunction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default createPlugin
|