<commit_before>import { trackList } from './globals';
import { viewport } from './viewport';

/**
 * Helper factory delivering the user scrolled distance of an element.
 *
 * @param {object} dimensions: elements dimensions
 * @param {object} view: object containing window information
 * @return {object} the distance the element has travelled because of user scroll
 */
const calculateScrolled = (dimensions, view) => {
	return view.scroll.y - dimensions.top + view.dimensions.height;
};

/**
 * Helper factory determining if an element should be redrawn
 *
 * @param {object} rect: an elements boundingClientRect.
 * @param {object} view: view object containing window pageYoffset and innerheight
 * @return {boolean} deciding if an element should be redrawn.
 */
const shouldRedraw = (rect, view) => {
	const startPoint = rect.top - view.dimensions.height;
	const endPoint = rect.bottom;

	return view.scroll.y > startPoint && view.scroll.y < endPoint;
};

/**
 * Function initiating tracked elements callback and exposing
 * needed parameters if their condition(s) are met.
 */
export default (forceAll = false) => {
	for (let i = trackList.length - 1; i >= 0; i--) {
		const item = trackList[i];
		let initiateCallback = Boolean(forceAll);

		if (!forceAll) {
			if (typeof item.config.shouldRedraw !== 'undefined') {
				if (typeof item.config.shouldRedraw === 'function') {<commit_msg>Reduce lines<commit_after>import { trackList } from './globals';
import { viewport } from './viewport';

/**
 * Helper factory delivering the user scrolled distance of an element.
 *
 * @param {object} dimensions: elements dimensions
 * @param {object} view: object containing window information
 * @return {object} the distance the element has travelled because of user scroll
 */
const calculateScrolled = (dimensions, view) => view.scroll.y - dimensions.top + view.dimensions.height;

/**
 * Helper factory determining if an element should be redrawn
 *
 * @param {object} rect: an elements boundingClientRect.
 * @param {object} view: view object containing window pageYoffset and innerheight
 * @return {boolean} deciding if an element should be redrawn.
 */
const shouldRedraw = (rect, view) => {
	const startPoint = rect.top - view.dimensions.height;
	const endPoint = rect.bottom;

	return view.scroll.y > startPoint && view.scroll.y < endPoint;
};

/**
 * Function initiating tracked elements callback and exposing
 * needed parameters if their condition(s) are met.
 */
export default (forceAll = false) => {
	for (let i = trackList.length - 1; i >= 0; i--) {
		const item = trackList[i];
		let initiateCallback = Boolean(forceAll);

		if (!forceAll) {
			if (typeof item.config.shouldRedraw !== 'undefined') {
				if (typeof item.config.shouldRedraw === 'function') {
{'fraction_non_alphanumeric': 0.1187725631768953, 'fraction_numerical': 0.001444043321299639, 'mean_word_length': 4.189138576779026, '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': '7015311', 'n_tokens_mistral': 799, 'n_tokens_neox': 768, 'n_words': 284}