Last active
November 25, 2017 19:48
-
-
Save idettman/eb042db0945bb1fddd9f to your computer and use it in GitHub Desktop.
JavaScript maybe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function maybe(fn) { | |
| let i = 0, length = 0 | |
| return function () { | |
| length = arguments.length | |
| if (length) { | |
| for (i = 0; i < length; ++i) { | |
| if (!arguments[i]) { | |
| return; | |
| } | |
| } | |
| return fn.apply(this, arguments); | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment