Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const updateBadge = (badgeOpt: BadgeDisplay): Task => async (): Promise => {
const urlRes = await pipe(
getActiveTab,
TO.chainOption(tab => O.fromNullable(tab.url)),
TO.chainOption(flow(
fromString,
O.fromEither,
)),
TO.map(flip(checkUrl)(urlState)),
runTask,
);
if (O.isSome(urlRes)) {
const [result, numMatches] = urlRes.value;
if (badgeOpt === BadgeDisplay.None || result === URLMatch.None) {
disableBadge();
return;
}
const text = badgeOpt === BadgeDisplay.WithCount
? String(numMatches)
: ' ';
switch (result) {