function timeout(promise, duration, error) {
  return new Promise((resolve, reject) => {
    promise.then(resolve, reject);
    setTimeout(
      () => reject(error || new Error("Operation timed out")),
      duration,
    );
  });
}
// if a promise doesn't resolve/reject within a given duration it will reject
if a promise doesn't resolve/reject within a given duration it will reject
if a promise doesn ' t resolve / reject within a given duration it will reject
function timeout(promise, duration, error) {
  return new Promise((resolve, reject) => {
    promise.then(resolve, reject);
    setTimeout(
      () => reject(error || new Error("Operation timed out")),
      duration,
    );
  });
}
function timeout ( promise , duration , error ) { return new Promise ( ( resolve , reject ) => { promise . then ( resolve , reject ) ; setTimeout ( ( ) => reject ( error || new Error ( "Operation timed out" ) ) , duration , ) ; } ) ; }
if a promise doesn't resolve/reject within a given duration it will reject
if a promise doesn ' t resolve / reject within a given duration it will reject