<commit_before>import {
	PredefinedTableColumnState,
	TagTableColumnState,
} from './TableColumnSelector';

export const ALL_TAGS_COLUMN_KEY = 'All Tags';
export type TaggedResource = { id: number };
export interface ResourceTagBase {
	id: number;
	tag_key: string;
	value: string;
}

export const TableColumnStateStoredProps: Array<
	keyof PredefinedTableColumnState | keyof TagTableColumnState
> = ['key', 'selected', 'type', 'tagKey'];

export const getResourceTags = <T extends TaggedResource, P extends keyof T>(
	item: T,
	tagField: P,
) => item?.[tagField] as ResourceTagBase[] | undefined;

export const getFromLocalStorage = <T extends any>(
	key: string,
): T | undefined => {
	try {
		const val = localStorage.getItem(key);
		if (val != null) {
			return JSON.parse(val);
		}

		return undefined;
	} catch (err) {
		console.error(err);
		return undefined;
	}<commit_msg>Table: Remove the unnecessary id field requirement from the generic arg<commit_after>import {
	PredefinedTableColumnState,
	TagTableColumnState,
} from './TableColumnSelector';

export const ALL_TAGS_COLUMN_KEY = 'All Tags';
export type TaggedResource = {};
export interface ResourceTagBase extends TaggedResource {
	tag_key: string;
	value: string;
}

export const TableColumnStateStoredProps: Array<
	keyof PredefinedTableColumnState | keyof TagTableColumnState
> = ['key', 'selected', 'type', 'tagKey'];

export const getResourceTags = <T extends TaggedResource, P extends keyof T>(
	item: T,
	tagField: P,
) => item?.[tagField] as ResourceTagBase[] | undefined;

export const getFromLocalStorage = <T extends any>(
	key: string,
): T | undefined => {
	try {
		const val = localStorage.getItem(key);
		if (val != null) {
			return JSON.parse(val);
		}

		return undefined;
	} catch (err) {
		console.error(err);
		return undefined;
	}
{'fraction_non_alphanumeric': 0.11661166116611661, 'fraction_numerical': 0.0, 'mean_word_length': 5.124579124579125, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '2630509', 'n_tokens_mistral': 588, 'n_tokens_neox': 572, 'n_words': 168}