@onehat/data 1.19.28 → 1.19.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -2
- package/src/Repository/Repository.js +22 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onehat/data",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.30",
|
|
4
4
|
"description": "JS data modeling package with adapters for many storage mediums.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"homepage": "https://github.com/OneHatRepo/data#readme",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@onehat/events": "^1.6.6",
|
|
40
|
-
"async-wait-until": "^2.0.12",
|
|
41
40
|
"accounting-js": "^1.1.1",
|
|
42
41
|
"axios": "^1.4.0",
|
|
43
42
|
"chrono-node": "^2.6.3",
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
v4 as uuid,
|
|
8
8
|
} from 'uuid';
|
|
9
9
|
import moment from 'moment';
|
|
10
|
-
import { waitUntil } from 'async-wait-until';
|
|
11
10
|
import _ from 'lodash';
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -388,8 +387,28 @@ export default class Repository extends EventEmitter {
|
|
|
388
387
|
this.throwError('this.waitUntilDoneLoading is no longer valid. Repository has been destroyed.');
|
|
389
388
|
return;
|
|
390
389
|
}
|
|
390
|
+
|
|
391
|
+
function delayUntil(fn, maxAttempts = 100, interval = 100) {
|
|
392
|
+
return new Promise((resolve, reject) => {
|
|
393
|
+
let currentAttempt = 0;
|
|
394
|
+
const checkCondition = async () => {
|
|
395
|
+
currentAttempt++;
|
|
396
|
+
|
|
397
|
+
if (fn()) {
|
|
398
|
+
resolve();
|
|
399
|
+
} else if (currentAttempt < maxAttempts) {
|
|
400
|
+
setTimeout(checkCondition, interval);
|
|
401
|
+
} else {
|
|
402
|
+
reject(new Error('maxAttempts reached. Condition not met.'));
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
checkCondition();
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
391
410
|
|
|
392
|
-
await
|
|
411
|
+
await delayUntil(() => !this.isLoading);
|
|
393
412
|
}
|
|
394
413
|
|
|
395
414
|
/**
|
|
@@ -2194,6 +2213,7 @@ export default class Repository extends EventEmitter {
|
|
|
2194
2213
|
if (this.errorHandler) {
|
|
2195
2214
|
this.errorHandler(obj);
|
|
2196
2215
|
} else {
|
|
2216
|
+
this.emit('error', obj);
|
|
2197
2217
|
throw Error(obj);
|
|
2198
2218
|
}
|
|
2199
2219
|
}
|