Idiomatic Way to Handle Optional Values in Effect Typescript

what's the more idiomatic way of doing this?

Effect.promise(() => storage.get(key)).pipe(
  Effect.flatMap((value) => {
    if (value == null) return Effect.succeed(Option.none());
    if (typeof value === "string") return Effect.succeed(Option.some(value));
    if (value instanceof Uint8Array) return Effect.succeed(Option.some(Encoding.encodeBase64(value)));
    return Effect.fail(notStringError(key, value));
  })
),


Or is using the generator fine?

Feel like I should be piping with Option.fromNullable etc...
Was this page helpful?