<commit_before>import { Injectable } from '@angular/core'
import { Observable, Observer } from 'rxjs'

import { Doc } from '../../core/Doc'
import { LocalStorageService } from '../../core/storage/local-storage/local-storage.service'

import { JoinEvent, RichLogootSOperation, State } from 'mute-core'


@Injectable()
export class SyncStorageService {

  private doc: Doc

  private storedStateObservable: Observable<State>
  private storedStateObservers: Observer<State>[] = []

  constructor (private localStorageService: LocalStorageService) {
    this.storedStateObservable = Observable.create((observer) => {
      this.storedStateObservers.push(observer)
    })
  }

  set initSource (source: Observable<Doc>) {
    source.subscribe((doc: Doc) => {
      this.doc = doc
      this.localStorageService.getBody(doc)
        .then((data: any) => {
          const richLogootSOps: RichLogootSOperation[] = data.richLogootSOps
            .map((richLogootSOp: any): RichLogootSOperation | null => {
              return RichLogootSOperation.fromPlain(richLogootSOp)
            })
            .filter((richLogootSOp: RichLogootSOperation | null) => {
              return richLogootSOp instanceof RichLogootSOperation
            })
          this.storedStateObservers.forEach((observer: Observer<State>) => {
            observer.next(new State(new Map(), richLogootSOps))
          })
        })
        .catch((err) => {
          log.error('Error getting document body of: ', doc)
          this.storedStateObservers.forEach((observer: Observer<State>) => {
            observer.next(new State(new Map(), []))
          })
        })
    })
  }

  set stateSource (source: Observable<State>) {
    source
      .bufferTime(750)
      .filter((states: State[]) => states.length > 0)
      .subscribe((states: State[]) => {
        const lastIndex = states.length - 1
        this.localStorageService.save(this.doc, states[lastIndex])
      })
  }

  get onStoredState(): Observable<State> {
    return this.storedStateObservable
  }
}<commit_msg>style(sync-storage): add missing white-space<commit_after>import { Injectable } from '@angular/core'
import { Observable, Observer } from 'rxjs'

import { Doc } from '../../core/Doc'
import { LocalStorageService } from '../../core/storage/local-storage/local-storage.service'

import { JoinEvent, RichLogootSOperation, State } from 'mute-core'


@Injectable()
export class SyncStorageService {

  private doc: Doc

  private storedStateObservable: Observable<State>
  private storedStateObservers: Observer<State>[] = []

  constructor (private localStorageService: LocalStorageService) {
    this.storedStateObservable = Observable.create((observer) => {
      this.storedStateObservers.push(observer)
    })
  }

  set initSource (source: Observable<Doc>) {
    source.subscribe((doc: Doc) => {
      this.doc = doc
      this.localStorageService.getBody(doc)
        .then((data: any) => {
          const richLogootSOps: RichLogootSOperation[] = data.richLogootSOps
            .map((richLogootSOp: any): RichLogootSOperation | null => {
              return RichLogootSOperation.fromPlain(richLogootSOp)
            })
            .filter((richLogootSOp: RichLogootSOperation | null) => {
              return richLogootSOp instanceof RichLogootSOperation
            })
          this.storedStateObservers.forEach((observer: Observer<State>) => {
            observer.next(new State(new Map(), richLogootSOps))
          })
        })
        .catch((err) => {
          log.error('Error getting document body of: ', doc)
          this.storedStateObservers.forEach((observer: Observer<State>) => {
            observer.next(new State(new Map(), []))
          })
        })
    })
  }

  set stateSource (source: Observable<State>) {
    source
      .bufferTime(750)
      .filter((states: State[]) => states.length > 0)
      .subscribe((states: State[]) => {
        const lastIndex = states.length - 1
        this.localStorageService.save(this.doc, states[lastIndex])
      })
  }

  get onStoredState (): Observable<State> {
    return this.storedStateObservable
  }
}
{'fraction_non_alphanumeric': 0.12808716707021792, 'fraction_numerical': 0.002421307506053269, 'mean_word_length': 2.87887323943662, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 39, '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': '3507008', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1192, 'n_words': 227}