1function hashToUri(type, hash) { 2 const encodedBlurhash = encodeURI(hash).replace(/#/g, '%23').replace(/\?/g, '%3F'); 3 return `${type}:/${encodedBlurhash}`; 4} 5/** 6 * Converts a blurhash string (`blurhash:/<hash>/<width>/<height>` or <hash>/<width>/<height>) into an `ImageSource`. 7 * 8 * @return An ImageSource representing the provided blurhash. 9 * */ 10export function resolveBlurhashString(str) { 11 const [blurhash, width, height] = str.replace(/^blurhash:\//, '').split('/'); 12 return { 13 uri: hashToUri('blurhash', blurhash), 14 width: parseInt(width, 10) || 16, 15 height: parseInt(height, 10) || 16, 16 }; 17} 18/** 19 * Converts a thumbhash string (`thumbhash:/<hash>` or `<hash>`) into an `ImageSource`. 20 * 21 * @return An ImageSource representing the provided thumbhash. 22 * */ 23export function resolveThumbhashString(str) { 24 const thumbhash = str.replace(/^thumbhash:\//, ''); 25 return { 26 uri: hashToUri('thumbhash', thumbhash), 27 }; 28} 29//# sourceMappingURL=resolveHashString.js.map