{"size": 1000, "ext": "js", "max_stars_repo_path": "wordpress/wp-content/plugins/woo-gutenberg-products-block/assets/js/settings/shared/index.js", "max_stars_repo_name": "TOP-FASHION/topfashion-backend", "max_stars_repo_stars_event_min_datetime": "2021-10-14T12:06:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-14T12:06:25.000Z", "max_issues_repo_path": "wordpress/wp-content/plugins/woo-gutenberg-products-block/assets/js/settings/shared/index.js", "max_issues_repo_name": "TOP-FASHION/topfashion-backend", "max_issues_repo_issues_event_min_datetime": "2021-03-10T23:41:49.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-08T23:27:44.000Z", "max_forks_repo_path": "wordpress/wp-content/plugins/woo-gutenberg-products-block/assets/js/settings/shared/index.js", "max_forks_repo_name": "TOP-FASHION/topfashion-backend", "max_forks_repo_forks_event_min_datetime": "2021-08-14T10:29:11.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-21T18:08:12.000Z"}
{"max_stars_count": 1, "max_issues_count": 9, "max_forks_count": 2, "avg_line_length": 27.027027027, "max_line_length": 79, "alphanum_fraction": 0.681}
/**
 * Internal dependencies
 */
import { getSetting } from './get-setting';

/**
 * External dependencies
 */
import compareVersions from 'compare-versions';

export * from './default-constants';
export { setSetting } from './set-setting';

/**
 * Note: this attempts to coerce the wpVersion to a semver for comparison
 * This will result in dropping any beta/rc values.
 *
 * `5.3-beta1-4252` would get converted to `5.3.0-rc.4252`
 * `5.3-beta1` would get converted to `5.3.0-rc`.
 * `5.3` would not be touched.
 *
 * For the purpose of these comparisons all pre-release versions are normalized
 * to `rc`.
 */
export const compareWithWpVersion = ( version, operator ) => {
	let replacement = getSetting( 'wpVersion', '' ).replace(
		/-[a-zA-Z0-9]*[\-]*/,
		'.0-rc.'
	);
	replacement = replacement.endsWith( '.' )
		? replacement.substring( 0, replacement.length - 1 )
		: replacement;
	return compareVersions.compare( version, replacement, operator );
};

export { compareVersions, getSetting };
