Created
May 15, 2021 22:30
-
-
Save helabenkhalfallah/7765c2b209b5b247a0c98d221f505115 to your computer and use it in GitHub Desktop.
JS Curried Function (custom logger)
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
const log = level => (message, ...optionals) => { | |
switch (level) { | |
case 'INFO': | |
API.info(message, optionals) | |
break | |
case 'WARN': | |
API.warn(message, optionals) | |
break | |
case 'ERROR': | |
API.error(message, optionals) | |
break | |
default: | |
break | |
} | |
} | |
const infoLogger = log('INFO') // not executed | |
const errorLogger = log('ERROR') // not executed | |
const warnLogger = log('WARN') // not executed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment