carbonteq /FP

Matching

matchOpt and matchRes for branching on container state.

matchRes

Use matchRes to branch on Result:

import { ,  } from "@carbonteq/fp";

const  = .(42);

const  = (, {
  : () => `ok:${}`,
  : () => `err:${()}`,
});

matchOpt

Use matchOpt to branch on Option:

import { ,  } from "@carbonteq/fp";

const  = .("hello");

const  = (, {
  : () => `some:${}`,
  : () => "none",
});

On this page