Refactored Arch Angel, split off The Flourish. Added try URL util to simplify trying multiple actor URLs.

This commit is contained in:
DebaucheryLibrarian
2026-01-11 00:50:16 +01:00
parent 6cb990dbdb
commit 6338e8fb8d
10 changed files with 332 additions and 225 deletions

View File

@@ -60,7 +60,7 @@ function kgToLbs(kgs) {
}
function curateConvertInput(string) {
if (/[']|(fe*t)/.test(string)) {
if (/[']|(fe*o*t)/.test(string)) {
const result = string.match(/(\d+).*(\d+)/);
if (result) {
@@ -74,9 +74,6 @@ function curateConvertInput(string) {
function convertManyApi(input, to) {
const curatedInput = curateConvertInput(input);
console.log('CONVERT', input);
console.log('RESULT', curatedInput);
return Math.round(convertMany(curatedInput).to(to)) || null;
}

20
src/utils/try-urls.js Normal file
View File

@@ -0,0 +1,20 @@
const unprint = require('unprint');
async function tryUrls(urls, options) {
return urls.filter(Boolean).reduce(async (chain, url) => {
const acc = await chain;
if (acc?.res.ok) {
return acc;
}
const res = await unprint.get(url, options);
return {
res,
url,
};
}, Promise.resolve());
}
module.exports = tryUrls;