1 | /**
|
2 | * Safe chained function
|
3 | *
|
4 | * Will only create a new function if needed,
|
5 | * otherwise will pass back existing functions or null.
|
6 | *
|
7 | * @returns {function|null}
|
8 | */
|
9 | export default function createChainedFunction() {
|
10 | var args = [].slice.call(arguments, 0);
|
11 | if (args.length === 1) {
|
12 | return args[0];
|
13 | }
|
14 | return function chainedFunction() {
|
15 | for (var i = 0; i < args.length; i++) {
|
16 | if (args[i] && args[i].apply) {
|
17 | args[i].apply(this, arguments);
|
18 | }
|
19 | }
|
20 | };
|
21 | } |
\ | No newline at end of file |