You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let isTruthy x =>
switch (Js.Nullable.to_opt x) {
| None => false
| Some a => Js.to_bool a
};
let (|?) a b =>
switch a {
| None => b
| Some a => a
};
let isDefined x => Js.Nullable.to_opt x !== None;
/* TODO: @chenglou kill this */
let isSomeTrue a =>
switch a {
| None => false
| Some a => a
};
let nullUndefinedBooleanToOptionBool a =>
switch (Js.Nullable.to_opt a) {
| None => None
| Some a => Some (Js.to_bool a)
};
let optionBoolToNullUndefinedBoolean a =>
switch a {
| None => Js.Nullable.undefined
| Some a => Js.Nullable.return (Js.Boolean.to_js_boolean a)
};
let optionBoolToBoolean a =>
switch a {
| None => Js.false_
| Some a => Js.Boolean.to_js_boolean a
};
let listFilterMap f ls => {
let rec listFilterMap_ f ls accum =>
switch ls {
| [] => accum
| [item, ...rest] =>
switch (f item) {
| None => listFilterMap_ f rest accum
| Some item => listFilterMap_ f rest [item, ...accum]
}
};
listFilterMap_ f ls []
};
let arrayCompact l =>
l |>
Js.Array.filter (
fun item =>
switch item {
| None => false
| Some _ => true
}
) |>
Array.map (
fun
| None =>
raise (Invalid_argument "arrayCompact: sorry, something went wrong.")
| Some a => a
);
The text was updated successfully, but these errors were encountered:
let isTruthy x =>
switch (Js.Nullable.to_opt x) {
| None => false
| Some a => Js.to_bool a
};
let (|?) a b =>
switch a {
| None => b
| Some a => a
};
let isDefined x => Js.Nullable.to_opt x !== None;
/* TODO: @chenglou kill this */
let isSomeTrue a =>
switch a {
| None => false
| Some a => a
};
let nullUndefinedBooleanToOptionBool a =>
switch (Js.Nullable.to_opt a) {
| None => None
| Some a => Some (Js.to_bool a)
};
let optionBoolToNullUndefinedBoolean a =>
switch a {
| None => Js.Nullable.undefined
| Some a => Js.Nullable.return (Js.Boolean.to_js_boolean a)
};
let optionBoolToBoolean a =>
switch a {
| None => Js.false_
| Some a => Js.Boolean.to_js_boolean a
};
let listFilterMap f ls => {
let rec listFilterMap_ f ls accum =>
switch ls {
| [] => accum
| [item, ...rest] =>
switch (f item) {
| None => listFilterMap_ f rest accum
| Some item => listFilterMap_ f rest [item, ...accum]
}
};
listFilterMap_ f ls []
};
let arrayCompact l =>
l |>
Js.Array.filter (
fun item =>
switch item {
| None => false
| Some _ => true
}
) |>
Array.map (
fun
| None =>
raise (Invalid_argument "arrayCompact: sorry, something went wrong.")
| Some a => a
);
The text was updated successfully, but these errors were encountered: