function targetMapping(
	remainingRequest,
	isPattern,
	isSubpathMapping,
	mappingTarget,
	assert,
) {
	if (remainingRequest === undefined) {
		assert(mappingTarget, false);

		return mappingTarget;
	}

	if (isSubpathMapping) {
		assert(mappingTarget, true);

		return mappingTarget + remainingRequest;
	}

	assert(mappingTarget, false);

	let result = mappingTarget;

	if (isPattern) {
		result = result.replace(
			patternRegEx,
			remainingRequest.replace(/\$/g, "$$"),
		);
	}

	return result;
}
@param {string | undefined} remainingRequest remaining request when folder mapping, undefined for file mappings
@param {boolean} isPattern true, if mapping is a pattern (contains "*")
@param {boolean} isSubpathMapping true, for subpath mappings
@param {string} mappingTarget direct export
@param {(d: string, f: boolean) => void} assert asserting direct value
@returns {string} mapping result