<commit_before>import { GRID_PREFIX } from '../definition';
import * as css from '../services/css';

export class TdCtrl {
	static classify(element, column) {
		element.classList.add(css.escapeAttr(`${GRID_PREFIX}-${column.key}`));
		element.classList.add(css.escapeAttr(`${GRID_PREFIX}-${column.type}`));
		if (column.editor) {
			element.classList.add(css.escapeAttr(`${GRID_PREFIX}-${column.editor}`));
		}
	}

	static viewMode(element) {
		element.classList.remove(`${GRID_PREFIX}-edit`);
	}

	static editMode(element) {
		element.classList.add(`${GRID_PREFIX}-edit`);        
	}
}<commit_msg>strigify to td.ctrl<commit_after>import { GRID_PREFIX } from '../definition';
import * as css from '../services/css';
import {isFunction, isDate, isArray} from '../utility';

const toJson = JSON.stringify;
const toString = Object.prototype.toString;
const hasCustomToString = obj => isFunction(obj.toString) && obj.toString !== toString;

export class TdCtrl {
	static classify(element, column) {
		element.classList.add(css.escapeAttr(`${GRID_PREFIX}-${column.key}`));
		element.classList.add(css.escapeAttr(`${GRID_PREFIX}-${column.type}`));
		if (column.editor) {
			element.classList.add(css.escapeAttr(`${GRID_PREFIX}-${column.editor}`));
		}
	}

	static viewMode(element) {
		element.classList.remove(`${GRID_PREFIX}-edit`);
	}

	static editMode(element) {
		element.classList.add(`${GRID_PREFIX}-edit`);
	}

	static stringify(value) {
		if (value == null) { // null || undefined
			return '';
		}

		switch (typeof value) {
			case 'string':
				break;
			case 'number':
				value = '' + value;
				break;
			default:
				if (hasCustomToString(value) && !isArray(value) && !isDate(value)) {
					value = value.toString();
				} else {
					value = toJson(value);
				}
		}

		return value;
	}
}
{'fraction_non_alphanumeric': 0.18020022246941045, 'fraction_numerical': 0.0, 'mean_word_length': 4.244897959183674, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4634210', 'n_tokens_mistral': 652, 'n_tokens_neox': 609, 'n_words': 103}