const isNullish = (value) => {
    if (value === null || value === undefined)
        return true;
    if (typeof value === 'number' && (Number.isNaN(value) || !Number.isFinite(value))) {
        return true;
    }
    return false;
};
export const maybe = (value) => ({
    map: (fn) => isNullish(value) ? maybe(value) : maybe(fn(value)),
    flatMap: (fn) => isNullish(value) ? maybe(value) : fn(value),
    getOr: defaultValue => (isNullish(value) ? defaultValue : value),
});
