<commit_before>import Fetch	 				from '../internal/fetch';

export default {
	Get,
	GetFresh
};

var TAG_CACHE = {};
function _Cache( filter, value ) {
	if ( filter ) {
		TAG_CACHE['_'+filter] = value;
	}
}
function _Exists( filter ) {
	return !!TAG_CACHE['_'+filter];
}
function _Get( filter ) {
	return TAG_CACHE['_'+filter];
}


export function Get( filter ) {
	if ( _Exists(filter) ) {
		return Promise.resolve(_Get(filter));
	}

	return GetFresh(filter);
}
export function GetFresh( filter ) {
	return Fetch.Get(API_ENDPOINT+'/vx/tag/get/'+filter)
		.then( r => {
			if ( r.tag ) {
				_Cache(filter, r);
			}

			//r.fresh = true;	// Caching will incorrectly mark it as fresh
			return r;
		});
}<commit_msg>GetContains<commit_after>import Fetch	 				from '../internal/fetch';

export default {
	Get,
	GetFresh,
	GetAll,
	GetContains,
};

var TAG_CACHE = {};
function _Cache( filter, value ) {
	if ( filter ) {
		TAG_CACHE['_'+filter] = value;
	}
}
function _Exists( filter ) {
	return !!TAG_CACHE['_'+filter];
}
function _Get( filter ) {
	return TAG_CACHE['_'+filter];
}

export function GetContains( subString ) {
	pattern = new RegExp(subString.match(/^#?(.+)/)[1], 'i');
	GetAll()
		.then( (r) => {
			const newResponse = Object.assign({}, r);
			newResponse.tag = [];
			r.tag.forEach((tag) => {
				if (tag.name.match(pattern)) {
					newResponse.tag.push(tag);
				}
			});
			return Promise.resolve(newResponse);
		});
}

export function GetAll() {
		return Get('all');
}

export function Get( filter ) {
	if ( _Exists(filter) ) {
		return Promise.resolve(_Get(filter));
	}

	return GetFresh(filter);
}

export function GetFresh( filter ) {
	return Fetch.Get(API_ENDPOINT+'/vx/tag/get/'+filter)
		.then( r => {
			if ( r.tag ) {
				_Cache(filter, r);
			}

			//r.fresh = true;	// Caching will incorrectly mark it as fresh
			return r;
		});
}
{'fraction_non_alphanumeric': 0.1722282023681378, 'fraction_numerical': 0.0005382131324004305, 'mean_word_length': 3.4367541766109784, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5029786', 'n_tokens_mistral': 750, 'n_tokens_neox': 670, 'n_words': 151}