blob: 5b8f14d7a9b8c166dfac4ecf1975959d794128ca [file] [log] [blame]
// delay wraps the value toReturn in a Promise that will resolve
// after "delay" milliseconds.
export function delay(toReturn, delay=100) {
// we return a function that returns the promise so each call
// has a "fresh" promise and waits for the time.
return function() {
return new Promise((resolve) => {
setTimeout(resolve, delay);
}).then(() => {
return {
status: 200,
body: JSON.stringify(toReturn),
headers: {'content-type':'application/json'},
};
});
};
}