<commit_before>import { ChildProcess } from 'child_process';

import { getCommitElement } from './interface/commit-view';
import {
	constructProgressText,
	getScreenElement,
	getTextElement,
} from './interface/interface-elements';
import { getListElement } from './interface/list-view';
import { addCommits } from './redux/action-creators';
import { store } from './redux/store';
import {
	BlessedElement,
	IListElement,
	IState,
	Screen,
	ScrollableTextElement,
	TextElement,
} from './types/types';
import {
	getCommitContentSync,
	getGitLogProcess,
} from './util/git-util';

export function run(args: string[]): void {
	store.subscribe(renderScreen(getScreenElement()));

	let dataString = '';
	const gitLogProcess: ChildProcess = getGitLogProcess(args);

	gitLogProcess.stdout.setEncoding('utf8');
	gitLogProcess.stdout.on('data', (data: string) => dataString += data);
	gitLogProcess.on('close', () => store.dispatch(addCommits(dataString.split('\n'))));
}

function renderScreen(screen: Screen): () => Screen {
	let lastState: IState = store.getState();

	const commitContentMap: Map<string, string> = new Map();

	let commit: ScrollableTextElement;
	let list: IListElement;
	let progressBar: TextElement;

	return (): Screen => {
		const state: IState = store.getState();

		const {commits, index, SHA, view} = state;

		const lastView = lastState.view;

		const isNewView: boolean = view !== lastView;<commit_msg>app.ts - uses new screen composing function<commit_after>import { ChildProcess } from 'child_process';

import { getCommitElement } from './interface/commit-view';
import {
	constructProgressText,
	getTextElement,
} from './interface/interface-elements';
import { getListElement } from './interface/list-view';
import { getScreen } from './interface/screen';
import { addCommits } from './redux/action-creators';
import { store } from './redux/store';
import {
	BlessedElement,
	IListElement,
	IState,
	Screen,
	ScrollableTextElement,
	TextElement,
} from './types/types';
import {
	getCommitContentSync,
	getGitLogProcess,
} from './util/git-util';

export function run(args: string[]): void {
	store.subscribe(renderScreen(getScreen()));

	let dataString = '';
	const gitLogProcess: ChildProcess = getGitLogProcess(args);

	gitLogProcess.stdout.setEncoding('utf8');
	gitLogProcess.stdout.on('data', (data: string) => dataString += data);
	gitLogProcess.on('close', () => store.dispatch(addCommits(dataString.split('\n'))));
}

function renderScreen(screen: Screen): () => Screen {
	let lastState: IState = store.getState();

	const commitContentMap: Map<string, string> = new Map();

	let commit: ScrollableTextElement;
	let list: IListElement;
	let progressBar: TextElement;

	return (): Screen => {
		const state: IState = store.getState();

		const {commits, index, SHA, view} = state;

		const lastView = lastState.view;

		const isNewView: boolean = view !== lastView;
{'fraction_non_alphanumeric': 0.14527260179434093, 'fraction_numerical': 0.0006901311249137336, 'mean_word_length': 5.357456140350878, 'pattern_counts': {'":': 0, '<': 5, '<?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': '851968', 'n_tokens_mistral': 911, 'n_tokens_neox': 884, 'n_words': 213}