<commit_before>import { Injectable } from '@angular/core';
import { HmrState } from 'angular2-hmr';

@Injectable()
export class AppState {
  _state = { };

  constructor() {

  }

  // already return a clone of the current state
  get state() {
    return this._state = this._clone(this._state);
  }
  // never allow mutation
  set state(value) {
    throw new Error('do not mutate the `.state` directly');
  }


  get(prop?: any) {
    // use our state getter for the clone
    const state = this.state;
    return state.hasOwnProperty(prop) ? state[prop] : state;
  }

  set(prop: string, value: any) {
    // internally mutate our state
    return this._state[prop] = value;
  }


  _clone(object) {
    // simple document clone
    return JSON.parse(JSON.stringify( object ));
  }
}<commit_msg>Use app service to track app level uncaptured exceptions<commit_after>import { Injectable } from '@angular/core';
import { HmrState } from 'angular2-hmr';
import { Subject } from "rxjs/Subject";

@Injectable()
export class AppState {

  private _state = { };
  private _stateSubject = new Subject<any>();

  constructor() {

  }

  // already return a clone of the current state
  get state() {
    return this._state = this._clone(this._state);
  }
  // never allow mutation
  set state(value) {
    throw new Error('do not mutate the `.state` directly');
  }


  get(prop?: any) {
    // use our state getter for the clone
    const state = this.state;
    return state.hasOwnProperty(prop) ? state[prop] : state;
  }

  set(prop: string, value: any) {
    // internally mutate our state
    let newValue = this._state[prop] = value;
    this._stateSubject.next(this.state);
    return newValue;
  }

  get subject() {
    return this._stateSubject;
  }

  _clone(object) {
    // simple document clone
    return JSON.parse(JSON.stringify( object ));
  }
}
{'fraction_non_alphanumeric': 0.12385568120624664, 'fraction_numerical': 0.0010770059235325794, 'mean_word_length': 3.056768558951965, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4994953', 'n_tokens_mistral': 596, 'n_tokens_neox': 577, 'n_words': 173}