Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 344 Bytes

bouncer.md

File metadata and controls

22 lines (17 loc) · 344 Bytes

Bouncer Pattern

const isDefined = (value, name) => {
  if (value === undefined || value === null) {
    throw new Error(`"${name}" is required`)
  }
}

const doWork = async (job) => {
  isDefined(job, 'job')
}

const main = async () => {
  doWork()
}

main().catch(console.error)

References: