@onehat/data 1.22.41 → 1.22.43

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.22.41",
3
+ "version": "1.22.43",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/OneHatData.js CHANGED
@@ -552,7 +552,11 @@ export class OneHatData extends EventEmitter {
552
552
  throw new Error('this.getRepositoriesBy is no longer valid. OneHatData has been destroyed.');
553
553
  }
554
554
  if (firstOnly) {
555
- return _.find(this.repositories, filter);
555
+ const found = _.find(this.repositories, filter);
556
+ if (_.isArray(found) && !found.length) {
557
+ throw new Error('repository not found')
558
+ }
559
+ return found;
556
560
  }
557
561
  return _.filter(this.repositories, filter);
558
562
  }
@@ -588,13 +592,13 @@ export class OneHatData extends EventEmitter {
588
592
  * Get Repositories that share the given type
589
593
  * @return {Repository[]} repositories
590
594
  */
591
- getRepositoriesByType = (type) => {
595
+ getRepositoriesByType = (type, firstOnly = false) => {
592
596
  if (this.isDestroyed) {
593
597
  throw new Error('this.getRepositoriesByType is no longer valid. OneHatData has been destroyed.');
594
598
  }
595
599
  return this.getRepositoriesBy((repository) => {
596
600
  return repository.getType() === type;
597
- });
601
+ }, firstOnly);
598
602
  }
599
603
 
600
604
  /**