Created
August 10, 2023 13:30
-
-
Save juliandescottes/8f356a5bb4c9f06e163b686ca9c42ffa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function matchURLPattern(pattern, input) { | |
return pattern.test(input); | |
} | |
function parseURLPattern(patternObj) { | |
if (patternObj.type === "string") { | |
return new URLPattern(patternObj.pattern); | |
} else { | |
delete patternObj.type; | |
return new URLPattern(patternObj); | |
} | |
} | |
function ok(cond, message) { | |
if (cond) { | |
console.log("SUCCESS: " + message); | |
} else { | |
console.error("FAILED: " + message); | |
} | |
} | |
function equal(v1, v2, message) { | |
ok(v1 == v2, message + ` (${v1} == ${v2})`); | |
} | |
async function add_task(fn) { | |
try { | |
await fn(); | |
} catch (e) { | |
ok(false, e.message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment