<commit_before>export default {
  props: {
    service: {
      type: String,
      required: true
    },
    method: {
      type: String
    },
    query: {
      type: Object
    },
    queryWhen: {
      type: [ Boolean, Function ],
      default: true
    },
    // For get requests
    id: {
      type: [ Number, String ]
    },
    // If a separate query is desired to fetch data, use fetchQuery
    // The watchers will automatically be updated, so you don't have to write 'fetchQuery.propName'
    fetchQuery: {
      type: Object
    },
    watch: {
      type: Array,
      default () {
        return []
      }
    },
    immediate: {
      type: Boolean,
      default: true
    },
    local: {
      type: Boolean,
      default: false
    },
    editScope: {
      type: Function,
      default (scope) {
        return scope
      }
    }
  },
  computed: {
    findItems () {
      return this.$store.getters[`${this.service}/find`]({ query: this.query }).data
    },
    getItem () {
      const getArgs = this.getArgs(this.query)

      return this.$store.getters[`${this.service}/get`](getArgs.length === 1 ? this.id : getArgs)
    },
    items () {
      if (this.method === 'find') {
        return this.findItems
      } else if (this.method === 'get') {
        return this.getItem
      } else if (this.id !== undefined && this.id !== null) {
        return this.getItem
      } else {
        return this.findItems
      }
    }
  },
  methods: {
    getArgs (queryToUse) {
      const query = queryToUse || this.fetchQuery || this.query
      const getArgs = [this.id]

      if (query) {
        getArgs.push({ query })
      }

      return getArgs
    },
    findData () {
      const query = this.fetchQuery || this.query

      if (typeof this.queryWhen === 'function' ? this.queryWhen(this.query) : this.queryWhen) {
        return this.$store.dispatch(`${this.service}/find`, { query })
      }
    },
    getData () {
      const getArgs = this.getArgs()

      if (typeof this.queryWhen === 'function' ? this.queryWhen(...getArgs) : this.queryWhen) {
        return this.$store.dispatch(`${this.service}/get`, getArgs.length === 1 ? this.id : getArgs)
      }
    },
    fetchData () {
      if (!this.local) {
        if (this.method === 'find') {
          return this.findData()
        } else if (this.method === 'get') {
          return this.getData()
        } else if (this.id !== undefined && this.id !== null) {
          return this.getData()
        } else {
          return this.findData()
        }
      }
    }
  },
  watch: {
    id: 'fetchData'
  },
  created () {
    if (!this.$FeathersVuex) {
      throw new Error(`You must first Vue.use the FeathersVuex plugin before using the 'feathers-vuex-data' component.`)
    }
    if (!this.$store.state[this.service]) {
      throw new Error(`The '${this.service}' plugin cannot be found. Did you register the service with feathers-vuex?`)
    }

    if (this.fetchQuery || this.query || (this.id !== null && this.id !== undefined)) {
      this.watch.forEach(prop => {
        if (typeof prop !== 'string') {
          throw new Error(`Values in the 'watch' array must be strings.`)
        }
        if (this.fetchQuery) {
          if (prop.startsWith('query')) {
            prop.replace('query', 'fetchQuery')
          }
        }
        this.$watch(prop, this.fetchData)
      })

      if (this.immediate) {
        this.fetchData()
      }
    }
  },
  render () {
    const defaultScope = { items: this.items }
    const scope = this.editScope(defaultScope)

    return this.$scopedSlots.default(scope || defaultScope)
  }
}<commit_msg>isFindPending, isGetPending now in component scope<commit_after>export default {
  props: {
    service: {
      type: String,
      required: true
    },
    method: {
      type: String
    },
    query: {
      type: Object
    },
    queryWhen: {
      type: [ Boolean, Function ],
      default: true
    },
    // For get requests
    id: {
      type: [ Number, String ]
    },
    // If a separate query is desired to fetch data, use fetchQuery
    // The watchers will automatically be updated, so you don't have to write 'fetchQuery.propName'
    fetchQuery: {
      type: Object
    },
    watch: {
      type: Array,
      default () {
        return []
      }
    },
    immediate: {
      type: Boolean,
      default: true
    },
    local: {
      type: Boolean,
      default: false
    },
    editScope: {
      type: Function,
      default (scope) {
        return scope
      }
    }
  },
  data: () => ({
    isFindPending: false,
    isGetPending: false
  }),
  computed: {
    findItems () {
      return this.$store.getters[`${this.service}/find`]({ query: this.query }).data
    },
    getItem () {
      const getArgs = this.getArgs(this.query)

      return this.$store.getters[`${this.service}/get`](getArgs.length === 1 ? this.id : getArgs)
    },
    items () {
      if (this.method === 'find') {
        return this.findItems
      } else if (this.method === 'get') {
        return this.getItem
      } else if (this.id !== undefined && this.id !== null) {
        return this.getItem
      } else {
        return this.findItems
      }
    }
  },
  methods: {
    getArgs (queryToUse) {
      const query = queryToUse || this.fetchQuery || this.query
      const getArgs = [this.id]

      if (query) {
        getArgs.push({ query })
      }

      return getArgs
    },
    findData () {
      const query = this.fetchQuery || this.query

      if (typeof this.queryWhen === 'function' ? this.queryWhen(this.query) : this.queryWhen) {
        this.isFindPending = true

        return this.$store.dispatch(`${this.service}/find`, { query })
          .then(() => {
            this.isFindPending = false
          })
      }
    },
    getData () {
      const getArgs = this.getArgs()

      if (typeof this.queryWhen === 'function' ? this.queryWhen(...getArgs) : this.queryWhen) {
        this.isGetPending = true

        return this.$store.dispatch(`${this.service}/get`, getArgs.length === 1 ? this.id : getArgs)
          .then(() => {
            this.isGetPending = false
          })
      }
    },
    fetchData () {
      if (!this.local) {
        if (this.method === 'find') {
          return this.findData()
        } else if (this.method === 'get') {
          return this.getData()
        } else if (this.id !== undefined && this.id !== null) {
          return this.getData()
        } else {
          return this.findData()
        }
      }
    }
  },
  watch: {
    id: 'fetchData'
  },
  created () {
    if (!this.$FeathersVuex) {
      throw new Error(`You must first Vue.use the FeathersVuex plugin before using the 'feathers-vuex-data' component.`)
    }
    if (!this.$store.state[this.service]) {
      throw new Error(`The '${this.service}' plugin cannot be found. Did you register the service with feathers-vuex?`)
    }

    if (this.fetchQuery || this.query || (this.id !== null && this.id !== undefined)) {
      this.watch.forEach(prop => {
        if (typeof prop !== 'string') {
          throw new Error(`Values in the 'watch' array must be strings.`)
        }
        if (this.fetchQuery) {
          if (prop.startsWith('query')) {
            prop.replace('query', 'fetchQuery')
          }
        }
        this.$watch(prop, this.fetchData)
      })

      if (this.immediate) {
        this.fetchData()
      }
    }
  },
  render () {
    const { items, isFindPending, isGetPending } = this
    const defaultScope = { items, isFindPending, isGetPending }
    const scope = this.editScope(defaultScope)

    return this.$scopedSlots.default(scope || defaultScope)
  }
}
{'fraction_non_alphanumeric': 0.1436729396495782, 'fraction_numerical': 0.0005191434133679429, 'mean_word_length': 1.917834153729648, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1744514', 'n_tokens_mistral': 2348, 'n_tokens_neox': 2352, 'n_words': 564}