UNPKG

@neo4j-cypher/editor-support

Version:

Core functionality to support Cypher integration into editors

14 lines (13 loc) 508 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.retryOperation = void 0; const wait = ms => new Promise(r => setTimeout(r, ms)); const retryOperation = (operation, delay, times) => new Promise((resolve, reject) => operation().then(resolve).catch(reason => { if (times - 1 > 0) { return wait(delay).then(retryOperation.bind(null, operation, delay, times - 1)).then(resolve).catch(reject); } return reject(reason); })); exports.retryOperation = retryOperation;