Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save helabenkhalfallah/7765c2b209b5b247a0c98d221f505115 to your computer and use it in GitHub Desktop.
Save helabenkhalfallah/7765c2b209b5b247a0c98d221f505115 to your computer and use it in GitHub Desktop.
JS Curried Function (custom logger)
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