/*
 * @Author: 赵伟
 * @Date: 2024-10-12 14:27:29
 * @Description: 函数式编程
 */

export function safeInvoke<T, M>(
  fn: (value: T) => M | undefined | null,
): (value: T | undefined | null) => M | undefined | null {
  return (arg: T | undefined | null) => {
    if (arg === undefined || arg === null) {
      return arg as undefined | null;
    }
    return fn(arg);
  };
}
