How to use the fp-ts-contrib/lib/TaskOption.map function in fp-ts-contrib

To help you get started, we’ve selected a few fp-ts-contrib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SamHH / bukubrow-webext / src / modules / badge.ts View on Github external
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) {