Last active
September 17, 2020 10:33
-
-
Save atomita/bf01c712297b1d21d29610a110315d4e to your computer and use it in GitHub Desktop.
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 ifExpression (condition) { | |
| if ('function' == typeof condition ? condition() : condition) { | |
| return { | |
| then: (callback) => { | |
| const end = 'function' == typeof callback ? callback() : callback | |
| const res = { | |
| else: (callback) => ({ | |
| end | |
| }), | |
| elseif: (condition) => ({ | |
| then: (callback) => res | |
| }), | |
| end | |
| } | |
| return res | |
| } | |
| } | |
| } | |
| return { | |
| then: (callback) => { | |
| return { | |
| else: (callback) => ({ | |
| end: 'function' == typeof callback ? callback() : callback | |
| }), | |
| elseif: (condition) => ifExpression(condition), | |
| end: null | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment