<commit_before>export default class Shortcut {
	constructor(table, apply) {
		this.apply = apply;
		this.shortcuts = new Map();
		this.codeMap = new Map()
			.set(9, 'tab')
			.set(13, 'enter')
			.set(27, 'escape')
			.set(32, 'space')
			.set(33, 'pageUp')
			.set(34, 'pageDown')
			.set(35, 'end')
			.set(36, 'home')
			.set(37, 'left')
			.set(38, 'up')
			.set(39, 'right')
			.set(40, 'down')
			.set(113, 'f2');

		this.canExecute = table.isFocused;
		this.listener = table.keyDown
			.on('keydown', this.onKeyDown.bind(this));
	}

	translate(e) {
		const codes = [];
		if (e.ctrlKey) {
			codes.push('ctrl');
		}

		if (e.shiftKey) {
			codes.push('shift');
		}

		const char = (this.codeMap.get(e.keyCode) || String.fromCharCode(e.keyCode)).toLowerCase();
		codes.push(char);
		return codes.join('+');
	}

	onKeyDown(e) {
		if (this.canExecute()) {
			const code = this.translate(e);
			if (this.shortcuts.has(code)) {
				const cmds = this.shortcuts.get(code);
				cmds.forEach(cmd => {
					if (cmd.canExecute()) {
						e.preventDefault();
						this.apply(() => cmd.execute());
					}
				});
			}
		}
	}

	register(id, commands) {
		for (let value of commands.values()) {
			if (value.shortcut) {
				value.shortcut
					.toLowerCase()
					.split('|')
					.forEach(shortcut => {
						let temp = [];
						if (this.shortcuts.has(shortcut)) {
							temp = this.shortcuts.get(shortcut);
						}
						temp.push(value);
						this.shortcuts.set(shortcut, temp);
					});
			}
		}

		return () => {
			this.shortcuts.delete(id);
		};
	}
}<commit_msg>add onDestroy<commit_after>export default class Shortcut {
	constructor(table, apply) {
		this.apply = apply;
		this.shortcuts = new Map();
		this.codeMap = new Map()
			.set(9, 'tab')
			.set(13, 'enter')
			.set(27, 'escape')
			.set(32, 'space')
			.set(33, 'pageUp')
			.set(34, 'pageDown')
			.set(35, 'end')
			.set(36, 'home')
			.set(37, 'left')
			.set(38, 'up')
			.set(39, 'right')
			.set(40, 'down')
			.set(113, 'f2');

		this.canExecute = table.isFocused;
		this.listener = table.keyDown
			.on('keydown', this.onKeyDown.bind(this));
	}

	translate(e) {
		const codes = [];
		if (e.ctrlKey) {
			codes.push('ctrl');
		}

		if (e.shiftKey) {
			codes.push('shift');
		}

		const char = (this.codeMap.get(e.keyCode) || String.fromCharCode(e.keyCode)).toLowerCase();
		codes.push(char);
		return codes.join('+');
	}

	onKeyDown(e) {
		if (this.canExecute()) {
			const code = this.translate(e);
			if (this.shortcuts.has(code)) {
				const cmds = this.shortcuts.get(code);
				cmds.forEach(cmd => {
					if (cmd.canExecute()) {
						e.preventDefault();
						this.apply(() => cmd.execute());
					}
				});
			}
		}
	}

	register(id, commands) {
		for (let value of commands.values()) {
			if (value.shortcut) {
				value.shortcut
					.toLowerCase()
					.split('|')
					.forEach(shortcut => {
						let temp = [];
						if (this.shortcuts.has(shortcut)) {
							temp = this.shortcuts.get(shortcut);
						}
						temp.push(value);
						this.shortcuts.set(shortcut, temp);
					});
			}
		}

		return () => {
			this.shortcuts.delete(id);
		};
	}

	onDestroy() {
		this.listener.off();
	}
}
{'fraction_non_alphanumeric': 0.2001891551071879, 'fraction_numerical': 0.017023959646910468, 'mean_word_length': 2.6513233601841195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4894810', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1224, 'n_words': 209}