<commit_before>import { DocumentNode } from 'graphql';

import {
  Cache,
  CacheWrite,
  getFragmentQueryDocument,
  DataProxyReadFragmentOptions,
  DataProxyReadQueryOptions,
  DataProxyWriteQueryOptions,
  DataProxyWriteFragmentOptions,
  QueryWatch,
} from 'apollo-cache-core';

import {
  OptimisticStoreItem,
  ApolloReducerConfig,
  NormalizedCache,
  DiffResult,
  addTypenameToDocument,
  defaultDataIdFromObject,
  HeuristicFragmentMatcher,
} from '../';

import { writeResultToStore } from './writeToStore';
import { readQueryFromStore, diffQueryAgainstStore } from './readFromStore';

const defaultConfig: ApolloReducerConfig = {
  fragmentMatcher: new HeuristicFragmentMatcher().match,
  dataIdFromObject: defaultDataIdFromObject,
  addTypename: true,
};

export class InMemoryCache extends Cache {
  private data: NormalizedCache;
  private config: ApolloReducerConfig;
  private optimistic: OptimisticStoreItem[] = [];
  private watches: QueryWatch[] = [];
  private addTypename: boolean;

  constructor(
    initialStore: NormalizedCache = {},
    config: ApolloReducerConfig = {},
  ) {
    super();
    this.config = { ...defaultConfig, ...config };
    this.addTypename = this.config.addTypename ? true : false;
    this.data = initialStore;
  }

  public getData(): NormalizedCache {
    return this.data;
  }

  public getOptimisticData(): NormalizedCache {
    if (this.optimistic.length === 0) {
      return this.data;
    }

    const patches = this.optimistic.map(opt => opt.data);
    return Object.assign({}, this.data, ...patches) as NormalizedCache;
  }

  public reset(): Promise<void> {
    this.data = {};
    this.broadcastWatches();

    return Promise.resolve();
  }

  // deprecated, only for supporting reducers
  public applyTransformer(
    transform: (i: NormalizedCache) => NormalizedCache,
  ): void {
    this.data = transform(this.data);
    this.broadcastWatches();<commit_msg>Remove unused method that was left behind when we removed reducers<commit_after>import { DocumentNode } from 'graphql';

import {
  Cache,
  CacheWrite,
  getFragmentQueryDocument,
  DataProxyReadFragmentOptions,
  DataProxyReadQueryOptions,
  DataProxyWriteQueryOptions,
  DataProxyWriteFragmentOptions,
  QueryWatch,
} from 'apollo-cache-core';

import {
  OptimisticStoreItem,
  ApolloReducerConfig,
  NormalizedCache,
  DiffResult,
  addTypenameToDocument,
  defaultDataIdFromObject,
  HeuristicFragmentMatcher,
} from '../';

import { writeResultToStore } from './writeToStore';
import { readQueryFromStore, diffQueryAgainstStore } from './readFromStore';

const defaultConfig: ApolloReducerConfig = {
  fragmentMatcher: new HeuristicFragmentMatcher().match,
  dataIdFromObject: defaultDataIdFromObject,
  addTypename: true,
};

export class InMemoryCache extends Cache {
  private data: NormalizedCache;
  private config: ApolloReducerConfig;
  private optimistic: OptimisticStoreItem[] = [];
  private watches: QueryWatch[] = [];
  private addTypename: boolean;

  constructor(
    initialStore: NormalizedCache = {},
    config: ApolloReducerConfig = {},
  ) {
    super();
    this.config = { ...defaultConfig, ...config };
    this.addTypename = this.config.addTypename ? true : false;
    this.data = initialStore;
  }

  public getData(): NormalizedCache {
    return this.data;
  }

  public getOptimisticData(): NormalizedCache {
    if (this.optimistic.length === 0) {
      return this.data;
    }

    const patches = this.optimistic.map(opt => opt.data);
    return Object.assign({}, this.data, ...patches) as NormalizedCache;
  }

  public reset(): Promise<void> {
    this.data = {};
    this.broadcastWatches();

    return Promise.resolve();
{'fraction_non_alphanumeric': 0.10987520347259902, 'fraction_numerical': 0.0005425935973955507, 'mean_word_length': 4.237215909090909, 'pattern_counts': {'":': 0, '<': 5, '<?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': '254342', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1069, 'n_words': 240}