Refactored Arch Angel, split off The Flourish. Added try URL util to simplify trying multiple actor URLs.
This commit is contained in:
@@ -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
20
src/utils/try-urls.js
Normal 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;
|
||||
Reference in New Issue
Block a user