<commit_before>import { DeepPartial } from 'ts-essentials';

import State from './state';

type SimpleStorage = Pick<Storage, 'getItem' | 'setItem'>;

export type PartialState = DeepPartial<State> | undefined;

type StorageFactory = () => SimpleStorage;

interface Config {
  storageFactory: StorageFactory;
  serialize: (state: State) => string;
  deserialize: (state: string) => PartialState;
}

interface InitializedStorage {
  initialState: PartialState;
  saveChanges: (state: State) => void;
}

export function removeVersion<T extends { version: unknown }>(data: T): Omit<T, 'version'> {
  const munged: Record<string, unknown> = {...data};
  delete munged.version;
  return munged as Omit<T, 'version'>
}

export class InMemoryStorage {
  private data = {};

  public getItem(name: string): string {
    return this.data[name];
  }

  public setItem(name: string, value: string) {
    this.data[name] = value;
  }
}

const KEY = 'redux';

export function initializeStorage(config: Config) {
  return (): InitializedStorage => {
    const { storageFactory, serialize, deserialize } = config;

    const storage = validateStorage(storageFactory);<commit_msg>Remove implicit any from the storage<commit_after>import { DeepPartial } from 'ts-essentials';

import State from './state';

type SimpleStorage = Pick<Storage, 'getItem' | 'setItem'>;

export type PartialState = DeepPartial<State> | undefined;

type StorageFactory = () => SimpleStorage;

interface Config {
  storageFactory: StorageFactory;
  serialize: (state: State) => string;
  deserialize: (state: string) => PartialState;
}

interface InitializedStorage {
  initialState: PartialState;
  saveChanges: (state: State) => void;
}

export function removeVersion<T extends { version: unknown }>(data: T): Omit<T, 'version'> {
  const munged: Record<string, unknown> = {...data};
  delete munged.version;
  return munged as Omit<T, 'version'>
}

export class InMemoryStorage {
  private data: { [s: string]: string } = {};

  public getItem(name: string): string {
    return this.data[name];
  }

  public setItem(name: string, value: string) {
    this.data[name] = value;
  }
}

const KEY = 'redux';

export function initializeStorage(config: Config) {
  return (): InitializedStorage => {
    const { storageFactory, serialize, deserialize } = config;

    const storage = validateStorage(storageFactory);
{'fraction_non_alphanumeric': 0.12931760741364784, 'fraction_numerical': 0.0, 'mean_word_length': 4.750605326876514, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, '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': '5899084', 'n_tokens_mistral': 705, 'n_tokens_neox': 702, 'n_words': 203}