UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

15 lines (14 loc) 536 B
/** * 多参数空值合并函数 * @param {...any} args - 任意数量的参数 * @returns {any} 第一个非null/undefined的参数值 * @example * ```ts * coalesce(null, undefined, 'hello'); // 'hello' * coalesce(undefined, 0, 'x'); // 0 // 0 不是 null/undefined * coalesce(undefined, '', 'x'); // '' // 空串也保留 * coalesce(null, null, null); // null // 全部都是 null/undefined 时返回最后一个参数 * coalesce(); // undefined * ``` */ export declare function coalesce(...args: unknown[]): unknown;