In some cases, you might want to define your own logic to determine whether to return an ok value or err value. You can do this by using ok and err API.
import {ok, err,type Result} from'unwrapit'exportfunctionaddNumber(a:number, b:number):Result<number,string> {if (a < b) {returnerr('a should greater than b') }if (a === b) {returnerr("a shouldn't equal to b") }returnok(a + b)}