<commit_before>import { PackageJson } from '../packagejson/package-json';

interface All {
  [groupName: string]: Set<string>;
}

const groupNames = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
type GroupNames = 'dependencies' | 'devDependencies' | 'optionalDependencies' | 'peerDependencies';

const all: All = groupNames.reduce((acc, groupName: string) => {
  acc[groupName] = new Set();
  return acc;
}, {} as All);

export const add = (name: string, groupName: string = 'dependencies'): void => {
  all[groupName].add(name);

  if (groupName === 'peerDependencies') {
    add(name, 'devDependencies');
  }
};

export const get = (groupName: string = 'dependencies'): string[] => {
  return Array.from(all[groupName].keys());
};

export const has = (name: string, groupName: string | 'all' = 'dependencies'): boolean => {
  if (groupName === 'all') {
    return Object.keys(all).reduce(
      (acc: boolean, group: string): boolean => acc || has(name, group),
      false,
    );
  }

  return all[groupName].has(name);
};

export const remove = (name: string, groupName: string | 'all' = 'dependencies'): void => {
  if (groupName === 'all') {
    Object.keys(all).forEach((group: string) => {
      all[group].delete(name);
    });
  } else {
    all[groupName].delete(name);

    if (groupName === 'peerDependencies') {
      remove(name, 'devDependencies');
    }
  }
};

export const removeAll = (): void => {
  Object.keys(all).forEach((group: string) => {
    all[group].clear();
  });
};

export const importFromPkg = (pkg: PackageJson = { name: '', version: '' }): void => {
  groupNames.forEach((groupName: string): void => {
    const deps = pkg[groupName as GroupNames];

    if (deps) {
      Object.keys(deps).forEach((dependencyName) => {
        add(dependencyName, groupName);
      });
    }
  });
};
<commit_msg>fix: for sets the correct method is values<commit_after>import { PackageJson } from '../packagejson/package-json';

interface All {
  [groupName: string]: Set<string>;
}

const groupNames = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
type GroupNames = 'dependencies' | 'devDependencies' | 'optionalDependencies' | 'peerDependencies';

const all: All = groupNames.reduce((acc, groupName: string) => {
  acc[groupName] = new Set();
  return acc;
}, {} as All);

export const add = (name: string, groupName: string = 'dependencies'): void => {
  all[groupName].add(name);

  if (groupName === 'peerDependencies') {
    add(name, 'devDependencies');
  }
};

export const get = (groupName: string = 'dependencies'): string[] => {
  return Array.from(all[groupName].values());
};

export const has = (name: string, groupName: string | 'all' = 'dependencies'): boolean => {
  if (groupName === 'all') {
    return Object.keys(all).reduce(
      (acc: boolean, group: string): boolean => acc || has(name, group),
      false,
    );
  }

  return all[groupName].has(name);
};

export const remove = (name: string, groupName: string | 'all' = 'dependencies'): void => {
  if (groupName === 'all') {
    Object.keys(all).forEach((group: string) => {
      all[group].delete(name);
    });
  } else {
    all[groupName].delete(name);

    if (groupName === 'peerDependencies') {
      remove(name, 'devDependencies');
    }
  }
};

export const removeAll = (): void => {
  Object.keys(all).forEach((group: string) => {
    all[group].clear();
  });
};

export const importFromPkg = (pkg: PackageJson = { name: '', version: '' }): void => {
  groupNames.forEach((groupName: string): void => {
    const deps = pkg[groupName as GroupNames];

    if (deps) {
      Object.keys(deps).forEach((dependencyName) => {
        add(dependencyName, groupName);
      });
    }
  });
};

{'fraction_non_alphanumeric': 0.1832405197560329, 'fraction_numerical': 0.0, 'mean_word_length': 3.9242819843342036, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '7286657', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1150, 'n_words': 277}