返回自定义的联合函数, 返回从提供的参数验证函数返回true
的第一个参数。
使用Array.find()
返回从提供的参数验证函数返回true
的第一个参数。
const coalesceFactory = valid => (...args) => args.find(valid);
// const customCoalesce = coalesceFactory(_ => ![null, undefined, "", NaN].includes(_))
// customCoalesce(undefined, null, NaN, "", "Waldo") //-> "Waldo"
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8