mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-03 04:27:41 +08:00
23 lines
494 B
JavaScript
23 lines
494 B
JavaScript
/**
|
|
* Safe chained function
|
|
*
|
|
* Will only create a new function if needed,
|
|
* otherwise will pass back existing functions or null.
|
|
*
|
|
* @returns {function|null}
|
|
*/
|
|
export default function createChainedFunction () {
|
|
const args = [].slice.call(arguments, 0)
|
|
if (args.length === 1) {
|
|
return args[0]
|
|
}
|
|
|
|
return function chainedFunction () {
|
|
for (let i = 0; i < args.length; i++) {
|
|
if (args[i] && args[i].apply) {
|
|
args[i].apply(this, arguments)
|
|
}
|
|
}
|
|
}
|
|
}
|