<commit_before>'use strict'
import { Observable } from 'rx-lite'

import { Axe, AxeType } from '../Axe'
import AxeUi from '../AxeUi'
import { Config } from '../Config'
import { ExpressionFilter } from '../Filtering'
import * as utils from '../Utils'

/**
 * Creates a new instance of store
 * @class
 * @memberOf orb
 * @param  {object} config - configuration object
 */
export default class Store {

  constructor (config, forceUpdateCallback) {
    this.init = false
    this.dataMatrix = {}
    this.defaultfield = { name: '#undefined#' }
    this.forceUpdateCallback = forceUpdateCallback
    this.config = new Config(config)
    this.filters = new Map()
    Object.keys(this.config.preFilters).forEach(key => this.filters.set(key, this.config.preFilters[key]))
    this.sizes = this.getsizes()
    this.rowsUi = this.getrowsUi()
    this.columnsUi = this.getcolumnsUi()
    this.layout = this.getlayout()
    this.init = true
  }

  subscribe (datasource) {
    this.data = []
    this.filteredData = []
    let observableDatasource = null
    // datasource can be an observable, an array of arrays or an array of objects
    if (Array.isArray(datasource) && (Array.isArray(datasource[0]) || typeof datasource[0] === 'object')) {
      observableDatasource = Observable.of(datasource)
    } else if (Observable.isObservable(datasource)) {
      // datasource is a Rxjs observable
      observableDatasource = datasource
    }
    if (observableDatasource) observableDatasource.subscribe(this.push.bind(this))
  }

  push (payload) {
    let pushed
    let _data = this.data
    // Push data (array of objects, array of arrays or object) to this.data
    if (Array.isArray(payload) && (Array.isArray(payload[0]) || typeof payload[0] === 'object')) {<commit_msg>Add unsubscribe method to the store<commit_after>'use strict'
import { Observable } from 'rx-lite'

import { Axe, AxeType } from '../Axe'
import AxeUi from '../AxeUi'
import { Config } from '../Config'
import { ExpressionFilter } from '../Filtering'
import * as utils from '../Utils'

/**
 * Creates a new instance of store
 * @class
 * @memberOf orb
 * @param  {object} config - configuration object
 */
export default class Store {

  constructor (config, forceUpdateCallback) {
    this.init = false
    this.dataMatrix = {}
    this.defaultfield = { name: '#undefined#' }
    this.forceUpdateCallback = forceUpdateCallback
    this.config = new Config(config)
    this.filters = new Map()
    Object.keys(this.config.preFilters).forEach(key => this.filters.set(key, this.config.preFilters[key]))
    this.sizes = this.getsizes()
    this.rowsUi = this.getrowsUi()
    this.columnsUi = this.getcolumnsUi()
    this.layout = this.getlayout()
    this.init = true
  }

  subscribe (datasource) {
    this.data = []
    this.filteredData = []
    let observableDatasource = null
    // datasource can be an observable, an array of arrays or an array of objects
    if (Array.isArray(datasource) && (Array.isArray(datasource[0]) || typeof datasource[0] === 'object')) {
      observableDatasource = Observable.of(datasource)
    } else if (Observable.isObservable(datasource)) {
      // datasource is a Rxjs observable
      observableDatasource = datasource
    }
    if (observableDatasource) this.dataSubscription = observableDatasource.subscribe(this.push.bind(this))
  }

  unsubscribe () {
    if (this.dataSubscription) this.dataSubscription.unsubscribe()
  }

  push (payload) {
    let pushed
    let _data = this.data
    // Push data (array of objects, array of arrays or object) to this.data
    if (Array.isArray(payload) && (Array.isArray(payload[0]) || typeof payload[0] === 'object')) {
{'fraction_non_alphanumeric': 0.12844286883010636, 'fraction_numerical': 0.00218161985274066, 'mean_word_length': 3.462287104622871, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6796021', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1098, 'n_words': 296}