hashLength = (replacer, handler, assetInfo, hashName) => {
	/** @type {Replacer} */
	const fn = (match, arg, input) => {
		let result;
		const length = arg && Number.parseInt(arg, 10);

		if (length && handler) {
			result = handler(length);
		} else {
			const hash = replacer(match, arg, input);

			result = length ? hash.slice(0, length) : hash;
		}
		if (assetInfo) {
			assetInfo.immutable = true;
			if (Array.isArray(assetInfo[hashName])) {
				assetInfo[hashName] = [...assetInfo[hashName], result];
			} else if (assetInfo[hashName]) {
				assetInfo[hashName] = [assetInfo[hashName], result];
			} else {
				assetInfo[hashName] = result;
			}
		}
		return result;
	};

	return fn;
}
@param {ReplacerFunction} replacer replacer
@param {((arg0: number) => string) | undefined} handler handler
@param {AssetInfo | undefined} assetInfo asset info
@param {string} hashName hash name
@returns {Replacer} hash replacer function