make the commitment

new Promise((resolve, reject) => {
  if (ok) { resolve(result) }
  else { reject(error) }
})

for asynchronous programming. See: Promises

Comments