open-nomad/ui/app/utils/timeout.js
2023-04-10 15:36:59 +00:00

16 lines
362 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import RSVP from 'rsvp';
// An always failing promise used to race against other promises
export default function timeout(duration) {
return new RSVP.Promise((resolve, reject) => {
setTimeout(() => {
reject(`Timeout of ${duration}ms exceeded`);
}, duration);
});
}