Currently I choose Belt if it provides the necessary functionality. When it doesn’t drop down to Js.
why is Js.Option ignoring that convention?
Js.Option dates back to when the OCaml pipe operator |> was the only pipe operator and it pipes to the right most argument - i.e. Js.Option.getWithDefault was optimized for |> (and continues to work with it).
Belt on the other hand was designed according to the more recently adopted BuckleScript conventions.
Piping to the last argument makes sense in a language where functions are curried. For example giving Js.Option.getWithDefault its first argument creates a function where the default is already set, ready to be used with any number of option values.
That convenience was sacrificed for the new conventions. To compensate there is an expanded partial application notation:
/* let newFunc = Js.Option.getWithDefault(defaultValue); */
let newFunc = Belt.Option.getWithDefault(_, defaultValue);
but that may be deprecated in the future - so it’s back to
/* same argument order as Js.Option.getWithDefault(default, value) */
let makeNewFunc = (default, value) =>
Belt.Option.getWithDefault(value, default);
let newFunc = makeNewFunc(defaultValue);
For the gory details see