@onehat/data 1.19.17 → 1.19.18

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/data",
3
- "version": "1.19.17",
3
+ "version": "1.19.18",
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
  /**
@@ -374,6 +375,18 @@ export default class Repository extends EventEmitter {
374
375
  this.isLoading = bool;
375
376
  }
376
377
 
378
+ /**
379
+ * Async function that resolves when !isLoading
380
+ */
381
+ waitUntilDoneLoading = async (timeout = 10000) => {
382
+ if (this.isDestroyed) {
383
+ this.throwError('this.waitUntilDoneLoading is no longer valid. Repository has been destroyed.');
384
+ return;
385
+ }
386
+
387
+ await waitUntil(() => !this.isLoading, { timeout });
388
+ }
389
+
377
390
  /**
378
391
  * Marks this repository as loaded
379
392
  */