# elasticpress/4.2.2/assets/js/sync/utilities.js

ElasticPress, version 4.2.2. 60 lines.

- Page: https://pluginprobe.com/plugins/elasticpress/4.2.2/code/assets/js/sync/utilities.js
- Raw: https://pluginprobe.com/plugins/elasticpress/4.2.2/raw/assets/js/sync/utilities.js
- Modified: 2022-05-26T12:34:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/elasticpress/4.2.2/code/assets/js/sync/utilities.js#L10-L20`.

```javascript
/**
 * Clear sync parameter from the URL.
 *
 * @returns {void}
 */
export const clearSyncParam = () => {
	window.history.replaceState(
		{},
		document.title,
		document.location.pathname + document.location.search.replace(/&do_sync/, ''),
	);
};

/**
 * Get the total number of items from index meta.
 *
 * @param {object} indexMeta Index meta.
 * @returns {number} Number of items.
 */
export const getItemsTotalFromIndexMeta = (indexMeta) => {
	let itemsTotal = 0;

	if (indexMeta.current_sync_item) {
		itemsTotal += indexMeta.current_sync_item.found_items;
	}

	itemsTotal = indexMeta.sync_stack.reduce(
		(itemsTotal, sync) => itemsTotal + sync.found_items,
		itemsTotal,
	);

	itemsTotal += indexMeta.totals.failed;
	itemsTotal += indexMeta.totals.skipped;
	itemsTotal += indexMeta.totals.synced;

	return itemsTotal;
};

/**
 * Get the number of processed items from index meta.
 *
 * @param {object} indexMeta Index meta.
 * @returns {number} Number of processed items.
 */
export const getItemsProcessedFromIndexMeta = (indexMeta) => {
	let itemsProcessed = 0;

	if (indexMeta.current_sync_item) {
		itemsProcessed += indexMeta.current_sync_item.failed;
		itemsProcessed += indexMeta.current_sync_item.skipped;
		itemsProcessed += indexMeta.current_sync_item.synced;
	}

	itemsProcessed += indexMeta.totals.failed;
	itemsProcessed += indexMeta.totals.skipped;
	itemsProcessed += indexMeta.totals.synced;

	return itemsProcessed;
};

```
