@onehat/data 1.19.30 → 1.19.31
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 +2 -1
- package/src/Repository/Repository.js +2 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onehat/data",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.31",
|
|
4
4
|
"description": "JS data modeling package with adapters for many storage mediums.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -37,6 +37,7 @@
|
|
|
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",
|
|
40
41
|
"accounting-js": "^1.1.1",
|
|
41
42
|
"axios": "^1.4.0",
|
|
42
43
|
"chrono-node": "^2.6.3",
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
v4 as uuid,
|
|
8
8
|
} from 'uuid';
|
|
9
9
|
import moment from 'moment';
|
|
10
|
+
import { waitUntil } from 'async-wait-until';
|
|
10
11
|
import _ from 'lodash';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -387,28 +388,8 @@ export default class Repository extends EventEmitter {
|
|
|
387
388
|
this.throwError('this.waitUntilDoneLoading is no longer valid. Repository has been destroyed.');
|
|
388
389
|
return;
|
|
389
390
|
}
|
|
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
|
-
|
|
410
391
|
|
|
411
|
-
await
|
|
392
|
+
await waitUntil(() => !this.isLoading, { timeout });
|
|
412
393
|
}
|
|
413
394
|
|
|
414
395
|
/**
|