版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

26 lines
906 B

  1. var createPlugin = function (plugin, config) {
  2. return {
  3. handler: plugin,
  4. config: config,
  5. };
  6. };
  7. createPlugin.withOptions = function (pluginFunction, configFunction) {
  8. if (configFunction === void 0) { configFunction = function () { return ({}); }; }
  9. var optionsFunction = function (options) {
  10. if (options === void 0) { options = {}; }
  11. return {
  12. __options: options,
  13. handler: pluginFunction(options),
  14. config: configFunction(options),
  15. };
  16. };
  17. optionsFunction.__isOptionsFunction = true;
  18. // Expose plugin dependencies so that `object-hash` returns a different
  19. // value if anything here changes, to ensure a rebuild is triggered.
  20. optionsFunction.__pluginFunction = pluginFunction;
  21. optionsFunction.__configFunction = configFunction;
  22. return optionsFunction;
  23. };
  24. export { createPlugin as default };