fix.js 599 B

1234567891011121314151617181920212223242526
  1. import _ from 'lodash'
  2. import {baseConfigProcess} from "./config";
  3. import {lookupFn, lookupScope} from "./lib";
  4. class FixClass {
  5. @baseConfigProcess()
  6. fix(me, config) {
  7. const {fix} = config
  8. if (!fix) {
  9. return
  10. }
  11. const scope = lookupScope(me)
  12. if (_.isArray(fix)) {
  13. _.each(fix, (f) => {
  14. const fn = lookupFn(scope, f)
  15. fn.call(this, me, config)
  16. })
  17. } else if (_.isString(fix)) {
  18. const fn = lookupFn(scope, fix)
  19. fn.call(this, me, config)
  20. }
  21. }
  22. }