Design principles
byenull uses plain data and function pipelines. Those choices affect how you compose code, validate values, and handle asynchronous work. They also have trade-offs that are worth understanding before you adopt the API.
Options are plain objects
An Option is either { type: "Some", value } or { type: "None" }. It has no class instance, private state, or prototype methods. You can inspect it in a debugger and compare it with ordinary object assertions. JSON.stringify can serialize the object when its payload is also serializable. This makes it easy to send Options between server and client.
The trade-off is that values do not have methods such as option.map(...). You import the functions you need and use type guards or pipelines. This keeps the data independent of the operations performed on it.
Constructors normalize nullish values
some(null) and some(undefined) return None. The fn and maybe creators apply the same rule to nullish callback results. Code that consumes these results does not need a second check for a nullish payload.
Normalization is a constructor rule. It is not a guarantee about every object with an Option shape. Some<T> does not constrain T, and isOption checks the object's fields without inspecting the payload:
Prefer the creators when you want nullish normalization. If an Option-shaped object comes from an untrusted source, validate its Some.value separately before treating it as non-nullish.
Functions take data last
A call such as Option.map(fn) returns a function that waits for an Option. This makes the same function usable as a step in Option.pipe:
A single transformation has needs a separate call of the applied function, as doubled shows. A pipeline lists later steps in execution order, which avoids nesting a call around each preceding result. byenull uses this convention throughout instead of supporting both data-first and data-last variants.
Synchronous throws and Promise rejections differ
fn and maybe turn a nullish callback result into None. When the callback returns a Promise, they also turn a rejection into None. A synchronous throw before the callback returns a Promise propagates to the caller.
A throw inside an async function becomes a Promise rejection, so fn and maybe convert it to None. This distinction follows JavaScript's execution rules. It is not based on the kind of error thrown.
Converting a rejection to None discards its reason. Use a Result when the caller needs the rejection value for logging, recovery, or a user-facing message.
byenull follows byethrow where their behaviors overlap
byenull uses the namespace style, curried data-last functions, pipe, and Promise-aware combinators from @praha/byethrow. Code that uses both libraries can keep the same pipeline structure.
The two types still carry different information. None has no error field, while a byethrow Failure carries an error. toResult therefore requires an error for the empty case, and fromResult discards a failure's error. The shared conventions do not hide that difference.
byenull is meant as a companion library to byethrow, though you can use either one exclusively.